Annotations-0.2: Constructing, analyzing and destructing annotated trees

Safe HaskellSafe-Infered




type family ErrorAlg f e a :: *Source

Type family that converts pattern functors to convenient algebra types.

type ErrorAlg_PF f e a = forall ix. f (K0 a) ix -> Either e aSource

An error algebra over pattern functors.

class MkErrorAlg f whereSource

Converts convenient algebras to algebras that are able to work with pattern functors.


mkErrorAlg :: ErrorAlg f e a -> ErrorAlg_PF f e aSource


MkErrorAlg U 
(MkErrorAlg f, MkErrorAlg g) => MkErrorAlg (:+: f g) 
MkErrorAlg f => MkErrorAlg (:*: (I xi) f) 
MkErrorAlg f => MkErrorAlg (:*: (K a) f) 
MkErrorAlg f => MkErrorAlg (:>: f xi) 

errorCata :: HFunctor phi f => ErrorAlg_PF f e r -> phi ix -> HFix (K x :*: f) ix -> Except [(e, x)] rSource

Reduces a tree to a value according to the algebra, collecting potential errors. The errors are combined with the annotations in the tree at the positions at which the errors occurred.

(&) :: a -> b -> (a, b)Source

For constructing algebras that are made of nested pairs rather than n-ary tuples, it is helpful to use this pairing combinator.