Portability | portable |
---|---|

Stability | experimental |

Maintainer | Edward Kmett <ekmett@gmail.com> |

Safe Haskell | Safe-Inferred |

- substitute :: (Monad f, Eq a) => a -> f a -> f a -> f a
- substituteVar :: (Functor f, Eq a) => a -> a -> f a -> f a
- isClosed :: Foldable f => f a -> Bool
- closed :: Traversable f => f a -> Maybe (f b)

# Documentation

substitute :: (Monad f, Eq a) => a -> f a -> f a -> f aSource

replaces the free variable `substitute`

a p w`a`

with `p`

in `w`

.

`>>>`

["goodnight","Gracie","!!!"]`substitute "hello" ["goodnight","Gracie"] ["hello","!!!"]`

substituteVar :: (Functor f, Eq a) => a -> a -> f a -> f aSource

replaces a free variable `substituteVar`

a b w`a`

with another free variable `b`

in `w`

.

`>>>`

["Bob","Bob","Charlie"]`substituteVar "Alice" "Bob" ["Alice","Bob","Charlie"]`

isClosed :: Foldable f => f a -> BoolSource

A closed term has no free variables.

`>>>`

True`isClosed []`

`>>>`

False`isClosed [1,2,3]`

closed :: Traversable f => f a -> Maybe (f b)Source

If a term has no free variables, you can freely change the type of free variables it is parameterized on.

`>>>`

Nothing`closed [12]`

`>>>`

Just []`closed ""`

`>>>`

closed "" :: Maybe [b]`:t closed ""`