hydra-0.8.0: Type-aware transformations for data and programs
Safe HaskellSafe-Inferred
LanguageHaskell2010

Hydra.Rewriting

Description

Functions for type and term rewriting

Synopsis

Documentation

beneathTypeAnnotations :: (Type -> Type) -> Type -> Type Source #

Apply a transformation to the first type beneath a chain of annotations

expandTypedLambdas :: Term -> Term Source #

Recursively transform arbitrary terms like 'add 42' into terms like 'x.add 42 x', whose arity (in the absence of application terms) is equal to the depth of nested lambdas. This is useful for targets like Java with weaker support for currying.

inlineType :: Map Name Type -> Type -> Flow s Type Source #

Inline all type variables in a type using the provided schema. Note: this function is only appropriate for nonrecursive type definitions.

removeTermAnnotations :: Term -> Term Source #

Recursively remove term annotations, including within subterms

removeTypeAnnotations :: Type -> Type Source #

Recursively remove type annotations, including within subtypes

rewrite :: ((x -> y) -> x -> y) -> ((x -> y) -> x -> y) -> x -> y Source #

rewriteTerm :: ((Term -> Term) -> Term -> Term) -> Term -> Term Source #

rewriteTermM :: ((Term -> Flow s Term) -> Term -> Flow s Term) -> Term -> Flow s Term Source #

rewriteType :: ((Type -> Type) -> Type -> Type) -> Type -> Type Source #

rewriteTypeM :: ((Type -> Flow s Type) -> Type -> Flow s Type) -> Type -> Flow s Type Source #