{-# LANGUAGE TypeOperators, MultiParamTypeClasses, FlexibleInstances,
UndecidableInstances, RankNTypes, GADTs, ScopedTypeVariables #-}---------------------------------------------------------------------------------- |-- Module : Data.Comp.MultiParam.Annotation-- Copyright : (c) 2010-2011 Patrick Bahr, Tom Hvitved-- License : BSD3-- Maintainer : Tom Hvitved <hvitved@diku.dk>-- Stability : experimental-- Portability : non-portable (GHC Extensions)---- This module defines annotations on signatures.----------------------------------------------------------------------------------moduleData.Comp.MultiParam.Annotation((:&:)(..),(:*:)(..),DistAnn(..),RemA(..),liftA,liftA',stripA,propAnn,propAnnM,ann,project')whereimportqualifiedData.Comp.OpsasOimportData.Comp.MultiParam.HDifunctorimportData.Comp.MultiParam.TermimportData.Comp.MultiParam.SumimportData.Comp.MultiParam.OpsimportData.Comp.MultiParam.AlgebraimportControl.Monad{-| Transform a function with a domain constructed from a higher-order difunctor
to a function with a domain constructed with the same higher-order difunctor,
but with an additional annotation. -}liftA::(RemAss')=>(s'ab:->t)->sab:->tliftAfv=f(remAv){-| Transform a function with a domain constructed from a higher-order difunctor
to a function with a domain constructed with the same higher-order difunctor,
but with an additional annotation. -}liftA'::(DistAnns'ps,HDifunctors')=>(s'ab:->Cxths'cd)->sab:->CxthscdliftA'fv=letv'O.:&:p=projectAvinannp(fv'){-| Strip the annotations from a term over a higher-order difunctor with
annotations. -}stripA::(RemAgf,HDifunctorg)=>CxtFungfstripA=appSigFunremA{-| Lift a term homomorphism over signatures @f@ and @g@ to a term homomorphism
over the same signatures, but extended with annotations. -}propAnn::(DistAnnfpf',DistAnngpg',HDifunctorg)=>Homfg->Homf'g'propAnnhomf'=annp(homf)wherefO.:&:p=projectAf'{-| Lift a monadic term homomorphism over signatures @f@ and @g@ to a monadic
term homomorphism over the same signatures, but extended with annotations. -}propAnnM::(DistAnnfpf',DistAnngpg',HDifunctorg,Monadm)=>HomMmfg->HomMmf'g'propAnnMhomf'=liftM(annp)(homf)wherefO.:&:p=projectAf'{-| Annotate each node of a term with a constant value. -}ann::(DistAnnfpg,HDifunctorf)=>p->CxtFunfgannc=appSigFun(injectAc){-| This function is similar to 'project' but applies to signatures
with an annotation which is then ignored. -}-- bug in type checker? below is the inferred type, however, the type checker-- rejects it.-- project' :: (RemA f g, f :<: f1) => Cxt h f1 a -> Maybe (g (Cxt h f1 a))project'v=liftMremA$projectv