Safe Haskell | None |
---|---|
Language | Haskell2010 |
Extensions |
|
This small but extensible framework facilitates defining complex defaulting rules that are not handled by DefaultSignatures
, and reducing the overhead of giving instances to new datatypes by generating superclasses. One reason we might want this is when a superclass wants to be given a default by two different subclasses (ex: Bifunctor
and Profunctor
both could generate Functor
instances). See the example
internal library for how to implement instances of Impl
.
Synopsis
- class Impl c where
- type NamedMethods c = NamedExpQ (Methods c)
- type family as :-> r where ...
- type TypeQ = Q Type
- (!) :: WithParam p fn fn' => fn -> Param p -> fn'
- type (:!) (name :: Symbol) a = NamedF Identity a name
- data NamedF (f :: Type -> Type) a (name :: Symbol) where
- arg :: Name name -> (name :! a) -> a
Documentation
type NamedMethods c = NamedExpQ (Methods c) Source #
Reexports
type family as :-> r where ... infixr 0 Source #
Converts a variable number of arguments into curried form. Ex:
>>>
:!kind '[Int,String,Double] :-> IO ()
Int -> String -> Double -> IO ()
type (:!) (name :: Symbol) a = NamedF Identity a name #
Infix notation for the type of a named parameter.
data NamedF (f :: Type -> Type) a (name :: Symbol) where #
Assign a name to a value of type a
wrapped in f
.
#verbose True :: NamedF Identity Bool "verbose"
arg :: Name name -> (name :! a) -> a #
arg
unwraps a named parameter with the specified name. One way to use it is
to match on arguments with -XViewPatterns
:
fn (arg #t -> t) (arg #f -> f) = ...
This way, the names of parameters can be inferred from the patterns: no type
signature for fn
is required. In case a type signature for fn
is
provided, the parameters must come in the same order:
fn :: "t" :! Integer -> "f" :! Integer -> ... fn (arg #t -> t) (arg #f -> f) = ... -- ok fn (arg #f -> f) (arg #t -> t) = ... -- does not typecheck