functor-friends-0.1.0.0: Friendly helpers for your recursion schemes.

Data.Functor.Holey

Synopsis

# The Holey type family

type family Holey f Source #

If T is a type that is defined as a fixpoint, then a Holey T will be the type of "Ts with holes".

Instances

 type Holey (Fix f) Source # type Holey (Fix f) = Fix (HoleF f)

# Types

data HoleF f t Source #

HoleF f transforms the functor f to add "holes".

Constructors

 HoleF A hole. ExistingF (f t) A normal value.

Instances

 Source # Methodsfmap1 :: (f t -> g t) -> HoleF f t -> HoleF g t Source # Functor f => Functor (HoleF f) Source # Methodsfmap :: (a -> b) -> HoleF f a -> HoleF f b #(<\$) :: a -> HoleF f b -> HoleF f a # Eq (f t) => Eq (HoleF f t) Source # Methods(==) :: HoleF f t -> HoleF f t -> Bool #(/=) :: HoleF f t -> HoleF f t -> Bool # Ord (f t) => Ord (HoleF f t) Source # Methodscompare :: HoleF f t -> HoleF f t -> Ordering #(<) :: HoleF f t -> HoleF f t -> Bool #(<=) :: HoleF f t -> HoleF f t -> Bool #(>) :: HoleF f t -> HoleF f t -> Bool #(>=) :: HoleF f t -> HoleF f t -> Bool #max :: HoleF f t -> HoleF f t -> HoleF f t #min :: HoleF f t -> HoleF f t -> HoleF f t # Pretty (f (Fix (HoleF f))) => Pretty (HoleF f (Fix (HoleF f))) Source # Pretty-printer for holes. Methodspretty :: HoleF f (Fix (HoleF f)) -> String Source #

## Patterns for hiding Fix

pattern Hole :: forall t. Fix (HoleF t) Source #

pattern Existing :: forall t. t (Fix (HoleF t)) -> Fix (HoleF t) Source #

# Utility functions

whole :: Functor f => Fix f -> Fix (HoleF f) Source #

Upgrade a value of type T to a value of type T-with-holes, without actually introducing any holes.

plug :: Functor f => Fix f -> Fix (HoleF f) -> Fix f Source #

Fill all holes in a data structure with the given value.

punch :: Functor f => (Fix f -> Bool) -> Fix f -> Fix (HoleF f) Source #

Replace any substructure matching the predicate with a hole.