Commit db201353 authored by Lennart Kolmodin's avatar Lennart Kolmodin
Browse files

Merge branch 'feature/void-binary-instance'

parents 0b7abd9f 0adaed92
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#if MIN_VERSION_base(4,8,0) #if MIN_VERSION_base(4,8,0)
#define HAS_NATURAL #define HAS_NATURAL
#define HAS_VOID
#endif #endif
#if __GLASGOW_HASKELL__ >= 704 #if __GLASGOW_HASKELL__ >= 704
...@@ -43,6 +44,9 @@ module Data.Binary.Class ( ...@@ -43,6 +44,9 @@ module Data.Binary.Class (
import Data.Word import Data.Word
import Data.Bits import Data.Bits
import Data.Int import Data.Int
#ifdef HAS_VOID
import Data.Void
#endif
import Data.Binary.Put import Data.Binary.Put
import Data.Binary.Get import Data.Binary.Get
...@@ -128,6 +132,14 @@ class Binary t where ...@@ -128,6 +132,14 @@ class Binary t where
------------------------------------------------------------------------ ------------------------------------------------------------------------
-- Simple instances -- Simple instances
#ifdef HAS_VOID
-- Void never gets written nor reconstructed since it's impossible to have a
-- value of that type
instance Binary Void where
put = absurd
get = mzero
#endif
-- The () type need never be written to disk: values of singleton type -- The () type need never be written to disk: values of singleton type
-- can be reconstructed from the type alone -- can be reconstructed from the type alone
instance Binary () where instance Binary () where
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment