packages feed

generics-eot 0.2.1.2 → 0.3

raw patch · 7 files changed

+16/−21 lines, 7 files

Files

README.md view
@@ -1,5 +1,5 @@ `generics-eot` is a library for datatype generic programming that tries to be very simple to understand and use. It's heavily inspired by the awesome-`generics-sop` package (http://hackage.haskell.org/package/generics-sop).+[`generics-sop`](http://hackage.haskell.org/package/generics-sop) package.  Documentation can be found here: http://generics-eot.readthedocs.org/en/latest/
examples/Catamorphisms.hs view
@@ -35,7 +35,7 @@ instance Cata Void dest where   type Typ Void dest = dest   cata :: Void -> Proxy dest -> dest-  cata void = seq void (error "impossible")+  cata = absurd   cataConst Proxy = id  class Cons fields dest where
examples/ToString.hs view
@@ -46,7 +46,7 @@   toStringConss [] _ = error "impossible"  instance ToStringG Void where-  toStringConss _ void = seq void (error "impossible")+  toStringConss _ = absurd  class ToStringFields a where   toStringFields :: a -> [String]
generics-eot.cabal view
@@ -2,10 +2,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: b474ea69101a3a9e75802091552ed5f46295c83b037837798edc3c3b21dee721+-- hash: 6df104be937df5ce9342be8c11c0bdc70083eb7364767d4abc3751ab800a2361  name:           generics-eot-version:        0.2.1.2+version:        0.3 synopsis:       A library for generic programming that aims to be easy to understand category:       Generics homepage:       https://github.com/soenkehahn/generics-eot#readme
src/Generics/Eot.hs view
@@ -17,14 +17,15 @@   Constructor(..),   Fields(..), -  -- * Void-  Void,   -- * Useful Re-exports   Generic,   Proxy(..),+  Void,+  absurd,   ) where  import           Data.Proxy+import           Data.Void import           GHC.Exts (Constraint) import           GHC.Generics hiding (Datatype, Constructor) 
src/Generics/Eot/Eot.hs view
@@ -15,10 +15,10 @@  module Generics.Eot.Eot (   HasEotG(..),-  Void,   ) where  import           Data.Proxy+import           Data.Void import           GHC.Generics  -- * datatype@@ -55,20 +55,12 @@   toEotConstructors = Left . toEotFields . unM1   fromEotConstructors = \ case     Left fields -> M1 $ fromEotFields fields-    Right void -> seq void (error "impossible")---- | Uninhabited type.-data Void-  deriving (Generic)--deriving instance Show Void-deriving instance Eq Void-deriving instance Ord Void+    Right void -> absurd void  instance HasConstructorsG V1 where   type Constructors V1 = Void   toEotConstructors v1 = seq v1 (error "impossible")-  fromEotConstructors void = seq void (error "impossible")+  fromEotConstructors = absurd  -- * GEither @@ -92,7 +84,7 @@  instance Normalize Void b where   type GEither Void b = b-  gLeft void Proxy = seq void (error "impossible")+  gLeft void Proxy = absurd void   gRight Proxy b = b   gEither :: b -> Either Void b   gEither = Right
src/Generics/Eot/Tutorial.lhs view
@@ -169,11 +169,13 @@ - `Void`:   We need this instance to make the compiler happy, but it'll never be   used. If you look at the type you can also see that: an argument of type-  `Void` cannot be constructed.+  `Void` cannot be constructed. (Often the function `Data.Void.absurd` comes in+  handy for implementing these cases. `generics-eot` re-exports both the type+  `Data.Void.Void` and `Data.Void.absurd` for convenience.)  ``` haskell instance EotSerialize Void where-  eotSerialize _ void = seq void $ error "impossible"+  eotSerialize _n void = absurd void ```  - `(x, xs)`: