generics-eot 0.4.0.1 → 0.4.1.0
raw patch · 8 files changed
+30/−38 lines, 8 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Generics.Eot: data Proxy (t :: k) :: forall k. () => k -> Type
- Generics.Eot: instance (GHC.Generics.Generic a, Generics.Eot.ImpliedByGeneric a c f) => Generics.Eot.HasEot a
- Generics.Eot: type family Eot a :: *;
+ Generics.Eot: data Proxy (t :: k)
+ Generics.Eot: instance (GHC.Internal.Generics.Generic a, Generics.Eot.ImpliedByGeneric a c f) => Generics.Eot.HasEot a
+ Generics.Eot: type Eot a;
- Generics.Eot: Proxy :: Proxy
+ Generics.Eot: Proxy :: Proxy (t :: k)
- Generics.Eot: absurd :: () => Void -> a
+ Generics.Eot: absurd :: Void -> a
Files
- README.md +6/−2
- examples/Catamorphisms.hs +3/−2
- generics-eot.cabal +3/−3
- src/Generics/Eot.hs +3/−2
- src/Generics/Eot/Datatype.hs +4/−3
- src/Generics/Eot/Eot.hs +9/−8
- test/Generics/Eot/Tutorial.lhs +2/−3
- test/Generics/Eot/TutorialSpec.hs +0/−15
README.md view
@@ -1,5 +1,9 @@ `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`](http://hackage.haskell.org/package/generics-sop) package.+very simple to understand and use. Documentation can be found here: https://generics-eot.readthedocs.io/++## Alternatives++- [`generics-sop`](http://hackage.haskell.org/package/generics-sop) - `generics-eot` is heavily inspired by this awesome package.+- There's a fork of `generics-eot` vendored into [`knit`](https://github.com/pkamenarsky/knit): [`knit/vendor/generics-eot`](https://github.com/pkamenarsky/knit/tree/master/vendor/generics-eot). It gives access to field names of record types at the type-level, which the version at [github.com/soenkehahn/generics-eot](https://github.com/soenkehahn/generics-eot) does not. For more discussion, see [here](https://github.com/soenkehahn/generics-eot/pull/26).
examples/Catamorphisms.hs view
@@ -8,6 +8,7 @@ module Catamorphisms where +import Data.Kind import Generics.Eot catamorphism :: (HasEot a, Cata (Eot a) dest) =>@@ -15,7 +16,7 @@ catamorphism a proxy = cata (toEot a) proxy class Cata eot dest where- type Typ eot dest :: *+ type Typ eot dest :: Type cata :: eot -> Proxy dest -> Typ eot dest cataConst :: Proxy eot -> dest -> Typ eot dest @@ -39,7 +40,7 @@ cataConst Proxy = id class Cons fields dest where- type ConsFunc fields dest :: *+ type ConsFunc fields dest :: Type eotConsFunc :: ConsFunc fields dest -> fields -> dest instance Cons () dest where
generics-eot.cabal view
@@ -1,13 +1,13 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.31.1.+-- This file has been generated from package.yaml by hpack version 0.38.2. -- -- see: https://github.com/sol/hpack ----- hash: 50d659af680069ec9917ed6a35c1ca01a40f9e83cc751ac1801a407b1e7a0602+-- hash: 61b1b8512afc75a1284a5d2b9a257971eb7121e996fc24221e1c3e6c2b6470a4 name: generics-eot-version: 0.4.0.1+version: 0.4.1.0 synopsis: A library for generic programming that aims to be easy to understand description: Documentation is here: <https://generics-eot.readthedocs.io/> category: Generics
src/Generics/Eot.hs view
@@ -2,6 +2,7 @@ {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeFamilies #-}+{-# LANGUAGE TypeOperators #-} {-# LANGUAGE UndecidableInstances #-} -- | @generics-eot@ tries to be a library for datatype generic programming@@ -24,9 +25,9 @@ absurd, ) where +import Data.Kind import Data.Proxy import Data.Void-import GHC.Exts (Constraint) import GHC.Generics hiding (Datatype, Constructor) import Generics.Eot.Datatype@@ -66,7 +67,7 @@ -- These rules (and the end-markers) are necessary to make sure generic -- functions know exactly which parts of the generic representation are field -- types and which parts belong to the generic skeleton.- type Eot a :: *+ type Eot a :: Type -- | Convert a value of type @a@ to its generic representation. toEot :: a -> Eot a
src/Generics/Eot/Datatype.hs view
@@ -12,6 +12,7 @@ module Generics.Eot.Datatype where import Data.Maybe+import Data.Kind import Data.Proxy import qualified GHC.Generics as GHC import GHC.Generics hiding (Datatype(..), Constructor(..))@@ -45,7 +46,7 @@ -- * datatype -class GenericDatatype (a :: * -> *) where+class GenericDatatype (a :: Type -> Type) where datatypeC :: Proxy a -> Datatype instance (GHC.Datatype c, GenericConstructors f) =>@@ -57,7 +58,7 @@ -- * constructors -class GenericConstructors (a :: * -> *) where+class GenericConstructors (a :: Type -> Type) where getConstructors :: Proxy a -> [Constructor] instance (GenericConstructors a, GenericConstructors b) =>@@ -85,7 +86,7 @@ l@(Nothing : _) -> NoSelectors (length l) l@(Just _ : _) -> Selectors (catMaybes l) -class GenericFields (a :: * -> *) where+class GenericFields (a :: Type -> Type) where getFieldsC :: Proxy a -> [Maybe String] instance (GenericFields a, GenericFields b) =>
src/Generics/Eot/Eot.hs view
@@ -17,14 +17,15 @@ HasEotG(..), ) where +import Data.Kind import Data.Proxy import Data.Void import GHC.Generics -- * datatype -class HasEotG (a :: * -> *) where- type EotG a :: *+class HasEotG (a :: Type -> Type) where+ type EotG a :: Type toEotG :: a x -> EotG a fromEotG :: EotG a -> a x @@ -35,8 +36,8 @@ -- * constructors -class HasConstructorsG (a :: * -> *) where- type Constructors a :: *+class HasConstructorsG (a :: Type -> Type) where+ type Constructors a :: Type toEotConstructors :: a x -> Constructors a fromEotConstructors :: Constructors a -> a x @@ -65,7 +66,7 @@ -- * GEither class Normalize a b where- type GEither a b :: *+ type GEither a b :: Type gLeft :: a -> Proxy b -> GEither a b gRight :: Proxy a -> b -> GEither a b gEither :: GEither a b -> Either a b@@ -91,8 +92,8 @@ -- * fields -class HasFieldsG (a :: * -> *) where- type Fields a :: *+class HasFieldsG (a :: Type -> Type) where+ type Fields a :: Type toEotFields :: a x -> Fields a fromEotFields :: Fields a -> a x @@ -116,7 +117,7 @@ -- * heterogenous lists class Concat a b where- type a +++ b :: *+ type a +++ b :: Type (+++) :: a -> b -> (a +++ b) unConcat :: (a +++ b) -> (a, b)
test/Generics/Eot/Tutorial.lhs view
@@ -466,11 +466,10 @@ ``` haskell -- $ >>> putStrLn $ createTableStatement (Proxy :: Proxy A)--- <BLANKLINE> -- ...--- • No instance for (EotCreateTableStatement+-- • No instance for ‘EotCreateTableStatement -- Datatype--- (Either ([Char], (Int, ())) (Either (Int, (Bool, ())) Void)))+-- (Either ([Char], (Int, ())) (Either (Int, (Bool, ())) Void))’ -- arising from a use of ‘createTableStatement’ -- ... ```
test/Generics/Eot/TutorialSpec.hs view
@@ -1,9 +1,5 @@-{-# LANGUAGE CPP #-}- module Generics.Eot.TutorialSpec where -#if MIN_VERSION_base(4,9,0)- import Test.DocTest import Test.Hspec @@ -14,14 +10,3 @@ it "doctests" $ do doctest (words "test/Generics/Eot/Tutorial.lhs -isrc -pgmL markdown-unlit")--#else--import Test.Hspec--import Generics.Eot.Tutorial ()--spec :: Spec-spec = return ()--#endif