Map package:first-class-families

Type-level fmap for type-level functors. Note: this name clashes with Map from containers. FMap is provided as a synonym to avoid this.

Example

>>> data AddMul :: Nat -> Nat -> Exp Nat

>>> type instance Eval (AddMul x y) = (x TL.+ y) TL.* (x TL.+ y)

>>> :kind! Eval (Map (AddMul 2) '[0, 1, 2, 3, 4])
Eval (Map (AddMul 2) '[0, 1, 2, 3, 4]) :: [Nat]
= '[4, 9, 16, 25, 36]
Type-level bimap.
>>> :kind! Eval (Bimap ((+) 1) (Flip (-) 1) '(2, 4))
Eval (Bimap ((+) 1) (Flip (-) 1) '(2, 4)) :: (Nat, Nat)
= '(3, 3)
Map a function and concatenate the results. This is FoldMap specialized to the list monoid.
Type-level foldMap.
Default implementation of FoldMap.

Usage

To define an instance of FoldMap for a custom MyType for which you already have an instance of Foldr:
type instance Eval (FoldMap f (xs :: MyType a)) = FoldMapDefault_ f xs

Example

>>> :kind! FoldMapDefault_ Pure '[ 'EQ, 'LT, 'GT ]
FoldMapDefault_ Pure '[ 'EQ, 'LT, 'GT ] :: Ordering
= 'LT
Synonym of Map to avoid name clashes.
Pre-compose a binary function with a function for each argument.

Example

>>> :kind! Eval (Bicomap Fst Pure (||) '( 'False, 'Nothing) 'True)
Eval (Bicomap Fst Pure (||) '( 'False, 'Nothing) 'True) :: Bool
= 'True