Copyright | Lev Dvorkin (c) 2022 |
---|---|
License | MIT |
Maintainer | lev_135@mail.ru |
Stability | experimental |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Synopsis
- class (c a, Constr c a) => Bidirectional (c :: k -> Constraint) (a :: k) where
- type Constr c a :: Constraint
- class (c a, ConstrRec c a, Bidirectional c a) => BidirectionalRec (c :: k -> Constraint) (a :: k) where
- type ConstrRec c a :: Constraint
Documentation
class (c a, Constr c a) => Bidirectional (c :: k -> Constraint) (a :: k) Source #
Class for non-recursive bidirectional instances, i. e. for instances,
such that their components constraints (Constr
) is ordinary instance.
Arguments:
c
class for which we declare bidirectional instancea
data type for which instance is provided
For example:
instance Show a => Bidirectional Show [a] where type ConstrRec Show [a] = Show a
is correct Bidirectional
instance. If you want to have bidirectional
Show
instance in backward constraint, use BidirectionalRec
Instances for this class are supposed to be generated by
makeBidirectionalInstances
or by
decBidirectionalInstances
.
type Constr c a :: Constraint Source #
Constraint for backwards inference.
Should not be recursively bidirectional (it means that all constraints
should not be wrapped in Bidirectional
, e. g. Show a
but not
Bidirectional Show a
)
class (c a, ConstrRec c a, Bidirectional c a) => BidirectionalRec (c :: k -> Constraint) (a :: k) Source #
Class for recursive bidirectional instances, i. e. for instances, such
that components also have bidirectional instance. Use Bidirectional
non-recursive variant, if you need only one step in backward direction.
Arguments:
c
class for which we declare bidirectional instancea
data type for which instance is provided
For example, this is a nice recursive instance:
instance BidirectionalRec Show a => BidirectionalRec Show [a] where type ConstrRec Show [a] = BidirectionalRec Show a
but this one isn't (actually it should be a Bidirectional
instance):
instance Show a => BidirectionalRec Show [a] where type ConstrRec Show [a] = Show a
Instances for this class are supposed to be generated by
makeBidirectionalInstances
or by
decBidirectionalInstances
.
type ConstrRec c a :: Constraint Source #
Constraint for backwards inference.
Should be recursively bidirectional (it means that all constraints should
be wrapped in BidirectionalRec
, e. g. BidirectionalRec Show a
but not
simply Show a
)