map -package:containers -package:bytestring -package:blaze-html -package:dlist -package:basement -package:conduit -package:psqueues -package:os-string -package:text -package:amazonka-core -package:hedgehog -package:integration -package:regex-tdfa -package:filepath -package:vector -package:cql -package:invertible 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 Example where Ex :: a -> Example  -- Hide the type of examples to avoid brittleness in different GHC versions

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

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

>>> :kind! Ex (Eval (Map (AddMul 2) '[0, 1, 2, 3, 4]) :: [Nat])
Ex (Eval (Map (AddMul 2) '[0, 1, 2, 3, 4]) :: [Nat]) :: Example
= Ex [4, 9, 16, 25, 36]
Type-level bimap.

Example

>>> data Example where Ex :: a -> Example  -- Hide the type of examples to avoid brittleness in different GHC versions

>>> :kind! Ex (Eval (Bimap ((+) 1) (Flip (-) 1) '(2, 4)) :: (Natural, Natural))
Ex (Eval (Bimap ((+) 1) (Flip (-) 1) '(2, 4)) :: (Natural, Natural)) :: Example
= Ex '(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