Repository navigation
Conversation
Fixes #65. Introduces a poly-kinded type family to allow users to associate tags to type, and corresponding type synonyms for all capabilities to shorten constraint declarations. Also changes the Reader example to make use of that feature.
| import Test.Common | ||
| import Test.Hspec | ||
|
|
||
| data Tag = Foo | Bar |
There was a problem hiding this comment.
Rather than using -XDataKind, how about simply defining
data Foo
data BarSo as not to give the impression that TypeOf needs to be used with a closed kind?
There was a problem hiding this comment.
Good point. -XEmptyDataDecls it is, then !
There was a problem hiding this comment.
It's not necessary in recent versions of GHC, right?
| -- the type associated to a tag. | ||
| -- | ||
| -- It is poly-kinded, which allows users to define their own type of tags, and | ||
| -- not have to declare orphan type family instances. |
There was a problem hiding this comment.
I think a point missing from this comment is that it is not recommended to define TypeOf with symbols. The reason is that it is not compositional and has a high likelihood to interfere with other libraries' instances of TypeOf. That is: symbols all belong to the same global namespace (which is partly why instances with symbols are considered orphans).
It think it needs to be made clear.
There also needs to be an example with tags made in *.
We could get away with TypeOf being defined only on *. But it's a nice plus that we can define it on any tag.
|
PTAL. |
| -- Standard haskell types can also be used as tags by specifying the '*' kind | ||
| -- when defining the type family instance. | ||
| -- | ||
| -- Defining 'TypeOf' instances for 'GHC.TypeLits.Symbol's (typelevel string |
There was a problem hiding this comment.
Please check that haddock renders the second link correctly.
Fixes #65.
Introduces a poly-kinded type family to allow users to associate tags to type, and corresponding type synonyms for all capabilities to shorten constraint declarations.
Also changes the 'Reader' example to make use of this feature.