Safe Haskell | None |
---|---|
Language | Haskell2010 |
- head :: CoRec f (r : rs) -> Maybe (f r)
- tail :: CoRec f (r : rs) -> Maybe (CoRec f rs)
- cons :: CoRec f rs -> CoRec f (r : rs)
- uncons :: CoRec f (r : rs) -> Either (f r) (CoRec f rs)
- apply :: Rec (Lift (->) f g) rs -> CoRec f rs -> CoRec g rs
- map :: (forall x. f x -> g x) -> CoRec f rs -> CoRec g rs
- replace :: Rec f rs -> CoRec f rs -> CoRec f rs
- modify :: Rec (Compose Endo f) rs -> CoRec f rs -> CoRec f rs
- modify' :: Rec Endo rs -> CoRec Identity rs -> CoRec Identity rs
- traverse :: Functor h => (forall x. f x -> h (g x)) -> CoRec f rs -> h (CoRec g rs)
- coalesce :: CoRec (Constant a) rs -> a
- coalesceWith :: (forall a. f a -> b) -> CoRec f rs -> b
- coalesceBy :: Rec (Compose (Op b) f) rs -> CoRec f rs -> b
- coalesceBy' :: Rec (Op b) rs -> CoRec Identity rs -> b
- lift :: RElem r rs i => f r -> CoRec f rs
- lift' :: RElem r rs i => r -> CoRec Identity rs
- just :: CoRec f rs -> CoRec (Compose Maybe f) rs
- right :: CoRec f rs -> CoRec (Compose (Either a) f) rs
Documentation
traverse :: Functor h => (forall x. f x -> h (g x)) -> CoRec f rs -> h (CoRec g rs) Source
There is not a actual traverse function for CoRec
. Notice how
this does not have an Applicative
constraint and consequently
does not combine contexts. It is provided for symmetry with the
traverse function available for Rec
.
coalesceWith :: (forall a. f a -> b) -> CoRec f rs -> b Source
coalesceBy' :: Rec (Op b) rs -> CoRec Identity rs -> b Source
Specialization of coalesceBy
that is more convenient for
working with an Identity
-parameterized CoRec
. This function
can be used to pattern-match on a CoRec
:
>>>
import Data.Char (ord)
>>>
:{
let handleVal = coalesceBy' $ Op ord :& Op (id :: Int -> Int) :& Op (\b -> if b then 1 else 0) :& RNil :}
Now we can reduce any CoRec
Identity
'[Char,Int,Bool]
to an Int
.
>>>
handleVal (lift' True)
1>>>
handleVal (lift' (44 :: Int))
44>>>
handleVal (lift' 'g')
103