generics-eot 0.4 → 0.4.0.1
raw patch · 2 files changed
+7/−7 lines, 2 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
+ Generics.Eot: --
+ Generics.Eot: -- </pre>
+ Generics.Eot: -- </ul>
+ Generics.Eot: -- <a>Either</a>s.</li>
+ Generics.Eot: -- <li>Again there's always an end-marker, this time of type <tt>()</tt>.
+ Generics.Eot: -- <li>The fields of one constructor are mapped to right-nested
+ Generics.Eot: -- <li>There's always a so-called end-marker <a>Void</a>. It's an invalid
+ Generics.Eot: -- <pre>
+ Generics.Eot: -- <ul>
+ Generics.Eot: -- A constructor with three fields <tt>a</tt>, <tt>b</tt>, <tt>c</tt> is
+ Generics.Eot: -- Either (Int, (Bool, ())) (Either (String, ()) Void)
+ Generics.Eot: -- These rules (and the end-markers) are necessary to make sure generic
+ Generics.Eot: -- accidentally create such a value). So e.g. <tt>data Foo = A</tt> would
+ Generics.Eot: -- be mapped to <tt>Either () Void</tt>, and a type with no constructors
+ Generics.Eot: -- choice (and <a>Void</a> is uninhabited to make sure you don't
+ Generics.Eot: -- data Foo = A Int Bool | B String
+ Generics.Eot: -- end-marker).</li>
+ Generics.Eot: -- field types and which parts belong to the generic skeleton.
+ Generics.Eot: -- functions know exactly which parts of the generic representation are
+ Generics.Eot: -- is mapped to <tt>Void</tt>.</li>
+ Generics.Eot: -- isomorphic generic representations. Here's an example:
+ Generics.Eot: -- mapped to <tt>(a, (b, (c, ())))</tt>, one field <tt>a</tt> is mapped
+ Generics.Eot: -- to <tt>(a, ())</tt>, and no fields are mapped to <tt>()</tt> (just the
+ Generics.Eot: -- tuples.</li>
+ Generics.Eot: -- would be mapped to:
+ Generics.Eot: -- | <a>Eot</a> is a type level function that maps arbitrary ADTs to
- Generics.Eot: Proxy :: Proxy k
+ Generics.Eot: Proxy :: Proxy
- Generics.Eot: data Void :: *
+ Generics.Eot: data Void
- Generics.Eot: data Proxy k (t :: k) :: forall k. () => k -> *
+ Generics.Eot: data Proxy (t :: k) :: forall k. () => k -> Type
Files
- generics-eot.cabal +5/−5
- test/Generics/Eot/Tutorial.lhs +2/−2
generics-eot.cabal view
@@ -1,11 +1,13 @@--- This file has been generated from package.yaml by hpack version 0.27.0.+cabal-version: 1.12++-- This file has been generated from package.yaml by hpack version 0.31.1. -- -- see: https://github.com/sol/hpack ----- hash: f78a8bf04b02774d2803f10fa8faa86e1590a5482402067e4af956c60fc06520+-- hash: 50d659af680069ec9917ed6a35c1ca01a40f9e83cc751ac1801a407b1e7a0602 name: generics-eot-version: 0.4+version: 0.4.0.1 synopsis: A library for generic programming that aims to be easy to understand description: Documentation is here: <https://generics-eot.readthedocs.io/> category: Generics@@ -15,8 +17,6 @@ license: BSD3 license-file: LICENSE build-type: Simple-cabal-version: >= 1.10- extra-source-files: README.md
test/Generics/Eot/Tutorial.lhs view
@@ -422,7 +422,7 @@ eotCreateTableStatement [] Proxy = error "impossible" ``` -The last instances is for `()`. It's needed as the base case for+The last instance is for `()`. It's needed as the base case for traversing the fields and as such returns just an empty list. ``` haskell@@ -431,7 +431,7 @@ eotCreateTableStatement (_ : _) Proxy = error "impossible" ``` -`createTableStatement` ties everything together. It obtaines the meta+`createTableStatement` ties everything together. It obtains the meta information through `datatype` passing a `Proxy` for `a`. And it creates a `Proxy` for the eot-type `Proxy :: Proxy (Eot a)`. Then it calls `eotCreateTableStatement` and just `concat`s the resulting snippets.