| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Blanks.Scope
Synopsis
- newtype Scope n f a = Scope {}
- pattern ScopeBound :: Int -> Scope n f a
- pattern ScopeFree :: a -> Scope n f a
- pattern ScopeBinder :: Int -> n -> Scope n f a -> Scope n f a
- pattern ScopeEmbed :: f (Scope n f a) -> Scope n f a
- scopeWFromInnerBinder :: ScopeWC t u n f g => BinderScope n (g a) -> u (g a)
- scopeBind :: Functor f => (a -> Scope n f b) -> Scope n f a -> Scope n f b
- scopeBindOpt :: Functor f => (a -> Maybe (Scope n f a)) -> Scope n f a -> Scope n f a
- scopeLift :: Traversable f => f a -> Scope n f a
- scopeInnerBinder :: (Functor f, Eq a) => n -> Seq a -> Scope n f a -> BinderScope n (Scope n f a)
- scopeInnerBinder1 :: (Functor f, Eq a) => n -> a -> Scope n f a -> BinderScope n (Scope n f a)
- scopeAbstract :: (Functor f, Eq a) => n -> Seq a -> Scope n f a -> Scope n f a
- scopeAbstract1 :: (Functor f, Eq a) => n -> a -> Scope n f a -> Scope n f a
- scopeUnAbstract :: Functor f => Seq a -> Scope n f a -> Scope n f a
- scopeUnAbstract1 :: Functor f => a -> Scope n f a -> Scope n f a
- scopeInstantiate :: Functor f => Seq (Scope n f a) -> Scope n f a -> Scope n f a
- scopeInstantiate1 :: Functor f => Scope n f a -> Scope n f a -> Scope n f a
- scopeApply :: Functor f => Seq (Scope n f a) -> Scope n f a -> Either SubError (Scope n f a)
- scopeApply1 :: Functor f => Scope n f a -> Scope n f a -> Either SubError (Scope n f a)
Documentation
A simple wrapper for your expression functor that knows how to name-bind.
Create free variables is pure, bind them with >>=, and list free variables with folds.
See LocScope for a version with additional annotations between layers.
Instances
| Functor f => Monad (Scope n f) Source # | |
| Functor f => Functor (Scope n f) Source # | |
| Functor f => Applicative (Scope n f) Source # | |
| Foldable f => Foldable (Scope n f) Source # | |
Defined in Blanks.Scope Methods fold :: Monoid m => Scope n f m -> m # foldMap :: Monoid m => (a -> m) -> Scope n f a -> m # foldMap' :: Monoid m => (a -> m) -> Scope n f a -> m # foldr :: (a -> b -> b) -> b -> Scope n f a -> b # foldr' :: (a -> b -> b) -> b -> Scope n f a -> b # foldl :: (b -> a -> b) -> b -> Scope n f a -> b # foldl' :: (b -> a -> b) -> b -> Scope n f a -> b # foldr1 :: (a -> a -> a) -> Scope n f a -> a # foldl1 :: (a -> a -> a) -> Scope n f a -> a # toList :: Scope n f a -> [a] # length :: Scope n f a -> Int # elem :: Eq a => a -> Scope n f a -> Bool # maximum :: Ord a => Scope n f a -> a # minimum :: Ord a => Scope n f a -> a # | |
| Traversable f => Traversable (Scope n f) Source # | |
Defined in Blanks.Scope | |
| (Eq (f (Scope n f a)), Eq n, Eq a) => Eq (Scope n f a) Source # | |
| (Show (f (Scope n f a)), Show n, Show a) => Show (Scope n f a) Source # | |
| (NFData n, NFData a, NFData (f (Scope n f a))) => NFData (Scope n f a) Source # | |
Defined in Blanks.Scope | |
| NatNewtype (ScopeW Identity n f (Scope n f)) (Scope n f) Source # | |
Defined in Blanks.Scope | |
pattern ScopeBound :: Int -> Scope n f a Source #
pattern ScopeEmbed :: f (Scope n f a) -> Scope n f a Source #
scopeWFromInnerBinder :: ScopeWC t u n f g => BinderScope n (g a) -> u (g a) Source #
scopeBind :: Functor f => (a -> Scope n f b) -> Scope n f a -> Scope n f b Source #
Substitution as a kind of monadic bind.
scopeBindOpt :: Functor f => (a -> Maybe (Scope n f a)) -> Scope n f a -> Scope n f a Source #
Optional substitution as another kind of monadic bind.
scopeLift :: Traversable f => f a -> Scope n f a Source #
Lift an expression functor into the scope functor.
scopeInnerBinder :: (Functor f, Eq a) => n -> Seq a -> Scope n f a -> BinderScope n (Scope n f a) Source #
scopeInnerBinder1 :: (Functor f, Eq a) => n -> a -> Scope n f a -> BinderScope n (Scope n f a) Source #
Arguments
| :: (Functor f, Eq a) | |
| => n | Annotation specific to your expression functor. Might contain original variable names and types, or might mark this as a "let" vs a "lambda" |
| -> Seq a | Free variables to bind, like the names of function parameters |
| -> Scope n f a | The expression to bind in, like the body of a function |
| -> Scope n f a |
Binds free variables in an expression and returns a binder.
scopeAbstract1 :: (Functor f, Eq a) => n -> a -> Scope n f a -> Scope n f a Source #
scopeAbstract for a single argument.
Arguments
| :: Functor f | |
| => Seq a | The names of the variables you're freeing |
| -> Scope n f a | The expression to substitute in (typically a binder) |
| -> Scope n f a |
Un-bind free variables in an expression. Basically the inverse of
scopeAbstract. Take care to match the arity of the binder! (scopeApply is safer.)
Arguments
| :: Functor f | |
| => Seq (Scope n f a) | Expressions to substitute in place of bound vars |
| -> Scope n f a | The expression to substitute in (typically a binder) |
| -> Scope n f a |
Instantiate the bound variables in an expression with other expressions.
Take care to match the arity of the binder! (scopeApply is safer.)
scopeInstantiate1 :: Functor f => Scope n f a -> Scope n f a -> Scope n f a Source #
scopeInstantiate for a single argument.
Arguments
| :: Functor f | |
| => Seq (Scope n f a) | Expressions to substitute in place of bound vars |
| -> Scope n f a | The binder expression to substitute in |
| -> Either SubError (Scope n f a) |
Instantiates the bound variables in an expression with other expressions.
Throws errors on mismatched arity, non binder expression, unbound vars, etc.
A version of scopeInstantiate that fails loudly instead of silently!
scopeApply1 :: Functor f => Scope n f a -> Scope n f a -> Either SubError (Scope n f a) Source #
scopeApply for a single argument.