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

Hydra.Rewriting

Description

Functions for type and term rewriting

Synopsis

Documentation

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 #

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

rewriteTypeM :: ((Type -> Flow s Type) -> Type -> Flow s Type) -> (Map String Term -> Flow s (Map String Term)) -> Type -> Flow s Type Source #

wrapLambdas :: Term -> Flow Graph Term Source #

Where non-lambda terms with nonzero arity occur at the top level, turn them into lambdas, also adding an appropriate type annotation to each new lambda.