| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
Overloaded.Constructors
Documentation
class HasConstructor x (s :: Type) (a :: Type) | x s -> a where Source #
Class for the overloaded constructors.
Instances for this class are automatically generated by type-checker
plugin, but you may also defined your own. See an example instances for Either.
{-# OPTIONS -fplugin=Overloaded -fplugin-opt=Overloaded:Constructors #-}
Additionally, this overload steals syntax transforming all
(:name arg1 arg2) into expressions.
Parenthesis are important as standalone build @"name" (arg1, arg2):name is (for now) not valid
Haskell syntax and they also naturally delimit the arguments.
For nullary constructors the a type is unit (),
for unary the type is used as is,
and for others the parameters are wrapped into a tuple.
The last case is not particularly pretty, but its overloadable.
Instances
| a' ~ a => HasConstructor "Left" (Either a b) a' Source # | |
| a' ~ b => HasConstructor "Right" (Either a b) a' Source # | |