Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- data ABT f v r
- data Term f v a = Term {}
- data Term' f v a x = Term' {
- freeVars' :: Set v
- annotation' :: a
- out' :: ABT f v x
- amap :: Functor f => (a -> a') -> Term f v a -> Term f v a'
- vmap :: (Functor f, Foldable f, Ord v') => (v -> v') -> Term f v a -> Term f v' a
- vmapM :: (Applicative m, Traversable f, Foldable f, Ord v2) => (v -> m v2) -> Term f v a -> m (Term f v2 a)
- transform :: (Ord v, Foldable g, Functor g) => (forall a. f a -> g a) -> Term f v a -> Term g v a
- transformM :: (Ord v, Monad m, Traversable g) => (forall a. f a -> m (g a)) -> Term f v a -> m (Term g v a)
- abs :: Ord v => a -> v -> Term f v a -> Term f v a
- var :: a -> v -> Term f v a
- cycle :: a -> Term f v a -> Term f v a
- tm :: (Foldable f, Ord v) => a -> f (Term f v a) -> Term f v a
- visit :: (Traversable f, Applicative g, Ord v) => (Term f v a -> Maybe (g (Term f v a))) -> Term f v a -> g (Term f v a)
- visit' :: (Traversable f, Monad g, Ord v) => (f (Term f v a) -> g (f (Term f v a))) -> Term f v a -> g (Term f v a)
- visit_ :: (Traversable f, Applicative g, Ord v) => (f (Term f v a) -> g ()) -> Term f v a -> g (Term f v a)
- visitPure :: (Traversable f, Ord v) => (Term f v a -> Maybe (Term f v a)) -> Term f v a -> Term f v a
- foreachSubterm :: (Traversable f, Applicative g) => (Term f v a -> g b) -> Term f v a -> g [b]
- subterms :: (Ord v, Traversable f) => Term f v a -> [Term f v a]
- pattern Var' :: v -> Term f v a
- pattern Cycle' :: [v] -> Term f v a -> Term f v a
- pattern AbsN' :: [v] -> Term f v a -> Term f v a
- pattern Tm' :: f (Term f v a) -> Term f v a
- unabs :: Term f v a -> ([v], Term f v a)
- freshInBoth :: Var v => Term f v a -> Term f v a -> v -> v
- substsInheritAnnotation :: (Foldable f, Functor f, Var v) => [(v, Term f v b)] -> Term f v a -> Term f v a
- substInheritAnnotation :: (Foldable f, Functor f, Var v) => v -> Term f v b -> Term f v a -> Term f v a
- subst' :: (Foldable f, Functor f, Var v) => (a -> Term f v a) -> v -> Set v -> Term f v a -> Term f v a
- rename :: (Foldable f, Functor f, Var v) => v -> v -> Term f v a -> Term f v a
- allVars :: Foldable f => Term f v a -> [v]
- freshenS :: (Var v, MonadState (Set v) m) => v -> m v
- freshenS' :: (Var v, MonadState s m) => Lens' s (Set v) -> v -> m v
Documentation
Instances
At each level in the tree, we store the set of free variables and
a value of type a
. Variables are of type v
.
Instances
Foldable f => Foldable (Term f v) Source # | |
Defined in U.Core.ABT fold :: Monoid m => Term f v m -> m # foldMap :: Monoid m => (a -> m) -> Term f v a -> m # foldMap' :: Monoid m => (a -> m) -> Term f v a -> m # foldr :: (a -> b -> b) -> b -> Term f v a -> b # foldr' :: (a -> b -> b) -> b -> Term f v a -> b # foldl :: (b -> a -> b) -> b -> Term f v a -> b # foldl' :: (b -> a -> b) -> b -> Term f v a -> b # foldr1 :: (a -> a -> a) -> Term f v a -> a # foldl1 :: (a -> a -> a) -> Term f v a -> a # elem :: Eq a => a -> Term f v a -> Bool # maximum :: Ord a => Term f v a -> a # minimum :: Ord a => Term f v a -> a # | |
Traversable f => Traversable (Term f v) Source # | |
Functor f => Functor (Term f v) Source # | |
Generic (Term f v a) Source # | |
(forall a1. Show a1 => Show (f a1), Show v) => Show (Term f v a) Source # | |
(Foldable f, Functor f, forall a1. Eq a1 => Eq (f a1), Var v) => Eq (Term f v a) Source # | |
(forall a1. Eq a1 => Eq (f a1), Foldable f, Functor f, forall a1. Ord a1 => Ord (f a1), Var v) => Ord (Term f v a) Source # | |
Functor f => Recursive (Term f v a) (Term' f v a) Source # | |
type Rep (Term f v a) Source # | |
Defined in U.Core.ABT type Rep (Term f v a) = D1 ('MetaData "Term" "U.Core.ABT" "unison-core-0.0.0-7TTEaGpY3e79hYDTKjX5dL" 'False) (C1 ('MetaCons "Term" 'PrefixI 'True) (S1 ('MetaSel ('Just "freeVars") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Set v)) :*: (S1 ('MetaSel ('Just "annotation") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a) :*: S1 ('MetaSel ('Just "out") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (ABT f v (Term f v a)))))) |
vmapM :: (Applicative m, Traversable f, Foldable f, Ord v2) => (v -> m v2) -> Term f v a -> m (Term f v2 a) Source #
transform :: (Ord v, Foldable g, Functor g) => (forall a. f a -> g a) -> Term f v a -> Term g v a Source #
transformM :: (Ord v, Monad m, Traversable g) => (forall a. f a -> m (g a)) -> Term f v a -> m (Term g v a) Source #
Traversals
visit :: (Traversable f, Applicative g, Ord v) => (Term f v a -> Maybe (g (Term f v a))) -> Term f v a -> g (Term f v a) Source #
`visit f t` applies an effectful function to each subtree of
t
and sequences the results. When f
returns Nothing
, visit
descends into the children of the current subtree. When f
returns
`Just t2`, visit
replaces the current subtree with t2
. Thus:
`visit (const Nothing) t == pure t` and
`visit (const (Just (pure t2))) t == pure t2`
visit' :: (Traversable f, Monad g, Ord v) => (f (Term f v a) -> g (f (Term f v a))) -> Term f v a -> g (Term f v a) Source #
Apply an effectful function to an ABT tree top down, sequencing the results.
visit_ :: (Traversable f, Applicative g, Ord v) => (f (Term f v a) -> g ()) -> Term f v a -> g (Term f v a) Source #
Apply an effectful function to an ABT tree top down, sequencing the results.
visitPure :: (Traversable f, Ord v) => (Term f v a -> Maybe (Term f v a)) -> Term f v a -> Term f v a Source #
foreachSubterm :: (Traversable f, Applicative g) => (Term f v a -> g b) -> Term f v a -> g [b] Source #
Patterns
freshInBoth :: Var v => Term f v a -> Term f v a -> v -> v Source #
Produce a variable which is free in both terms
substsInheritAnnotation :: (Foldable f, Functor f, Var v) => [(v, Term f v b)] -> Term f v a -> Term f v a Source #
substInheritAnnotation :: (Foldable f, Functor f, Var v) => v -> Term f v b -> Term f v a -> Term f v a Source #
subst' :: (Foldable f, Functor f, Var v) => (a -> Term f v a) -> v -> Set v -> Term f v a -> Term f v a Source #
rename :: (Foldable f, Functor f, Var v) => v -> v -> Term f v a -> Term f v a Source #
renames old
to new
in the given term, ignoring subtrees that bind old