Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
First-class type families
For example, here is a regular type family:
type family FromMaybe (a :: k) (m :: Maybe k) :: k type instance FromMaybe a 'Nothing = a type instance FromMaybe a ('Just b) = b
With Fcf
, it translates to a data
declaration:
data FromMaybe :: k -> Maybe k ->Exp
k type instanceEval
(FromMaybe a 'Nothing) = a type instanceEval
(FromMaybe a ('Just b)) = b
Synopsis
- type Exp a = a -> Type
- type family Eval (e :: Exp a) :: a
- data Pure :: a -> Exp a
- data Pure1 :: (a -> b) -> a -> Exp b
- data Pure2 :: (a -> b -> c) -> a -> b -> Exp c
- data Pure3 :: (a -> b -> c -> d) -> a -> b -> c -> Exp d
- data (=<<) :: (a -> Exp b) -> Exp a -> Exp b
- data (<=<) :: (b -> Exp c) -> (a -> Exp b) -> a -> Exp c
- data Join :: Exp (Exp a) -> Exp a
- data (<$>) :: (a -> b) -> Exp a -> Exp b
- data (<*>) :: Exp (a -> b) -> Exp a -> Exp b
- data Flip :: (a -> b -> Exp c) -> b -> a -> Exp c
- data Uncurry :: (a -> b -> Exp c) -> (a, b) -> Exp c
- data BimapPair :: (a -> Exp a') -> (b -> Exp b') -> (a, b) -> Exp (a', b')
- data UnEither :: (a -> Exp c) -> (b -> Exp c) -> Either a b -> Exp c
- data BimapEither :: (a -> Exp a') -> (b -> Exp b') -> Either a b -> Exp (Either a' b')
- data UnMaybe :: Exp b -> (a -> Exp b) -> Maybe a -> Exp b
- data Foldr :: (a -> b -> Exp b) -> b -> [a] -> Exp b
- data Traverse :: (a -> Exp b) -> [a] -> Exp [b]
- data UnList :: b -> (a -> b -> Exp b) -> [a] -> Exp b
- data UnBool :: Exp a -> Exp a -> Bool -> Exp a
- data (||) :: Bool -> Bool -> Exp Bool
- data (&&) :: Bool -> Bool -> Exp Bool
- type (@@) f x = Eval (f x)
- class IsBool (b :: Bool) where
- type family If (b :: Bool) (x :: k) (y :: k) :: k
First-class type families
type family Eval (e :: Exp a) :: a Source #
Expression evaluator.
Instances
type Eval (False && b :: Bool -> Type) Source # | |
type Eval (True && b :: Bool -> Type) Source # | |
type Eval (a && True :: Bool -> Type) Source # | |
type Eval (a && False :: Bool -> Type) Source # | |
type Eval (False || b :: Bool -> Type) Source # | |
type Eval (True || b :: Bool -> Type) Source # | |
type Eval (a || False :: Bool -> Type) Source # | |
type Eval (a || True :: Bool -> Type) Source # | |
type Eval (Pure x :: a -> Type) Source # | |
type Eval (Join e :: a -> Type) Source # | |
type Eval (Pure1 f x :: a2 -> Type) Source # | |
type Eval (k =<< e :: a2 -> Type) Source # | |
type Eval (f <$> e :: a2 -> Type) Source # | |
type Eval (f <*> e :: a2 -> Type) Source # | |
type Eval (UnBool fal tru True :: a -> Type) Source # | |
type Eval (UnBool fal tru False :: a -> Type) Source # | |
type Eval (Uncurry f ((,) x y) :: a2 -> Type) Source # | |
type Eval (UnMaybe y f (Just x) :: a2 -> Type) Source # | |
type Eval (UnMaybe y f (Nothing :: Maybe a1) :: a2 -> Type) Source # | |
type Eval (Foldr f y (x ': xs) :: a2 -> Type) Source # | |
type Eval (Foldr f y ([] :: [a1]) :: a2 -> Type) Source # | |
type Eval (UnList y f xs :: a2 -> Type) Source # | |
type Eval (Pure2 f x y :: a2 -> Type) Source # | |
type Eval ((f <=< g) x :: a3 -> Type) Source # | |
type Eval (Flip f y x :: a2 -> Type) Source # | |
type Eval (UnEither f g (Right y :: Either a2 b) :: a1 -> Type) Source # | |
type Eval (UnEither f g (Left x :: Either a2 b) :: a1 -> Type) Source # | |
type Eval (Pure3 f x y z :: a2 -> Type) Source # | |
type Eval (Traverse f (x ': xs) :: [b] -> Type) Source # | |
type Eval (Traverse f ([] :: [a]) :: [b] -> Type) Source # | |
type Eval (BimapEither f g (Right y :: Either a b1) :: Either a' b2 -> Type) Source # | |
type Eval (BimapEither f g (Left x :: Either a1 b) :: Either a2 b' -> Type) Source # | |
type Eval (BimapPair f g ((,) x y) :: (k2, k1) -> Type) Source # | |
Monadic operations
More higher-order combinators
data UnEither :: (a -> Exp c) -> (b -> Exp c) -> Either a b -> Exp c Source #
data BimapEither :: (a -> Exp a') -> (b -> Exp b') -> Either a b -> Exp (Either a' b') Source #
data UnList :: b -> (a -> b -> Exp b) -> [a] -> Exp b Source #
N.B.: This is equivalent to a Foldr
flipped.
data UnBool :: Exp a -> Exp a -> Bool -> Exp a Source #
N.B.: The order of the two branches is the opposite of "if":
UnBool ifFalse ifTrue bool
.
This mirrors the default order of constructors:
data Bool = False | True ----------- False < True