clash-lib-0.99.1: CAES Language for Synchronous Hardware - As a Library

Copyright(C) 2012-2016 University of Twente
2016 Myrtle Software Ltd
2017 Google Inc.
LicenseBSD2 (see the file LICENSE)
MaintainerChristiaan Baaij <christiaan.baaij@gmail.com>
Safe HaskellNone
LanguageHaskell2010

Clash.Rewrite.Types

Description

Type and instance definitions for Rewrite modules

Synopsis

Documentation

data CoreContext Source #

Context in which a term appears

Constructors

AppFun

Function position of an application

AppArg

Argument position of an application

TyAppC

Function position of a type application

LetBinding Id [Id]

RHS of a Let-binder with the sibling LHS'

LetBody [Id]

Body of a Let-binding with the bound LHS'

LamBody Id

Body of a lambda-term with the abstracted variable

TyLamBody TyVar

Body of a TyLambda-term with the abstracted type-variable

CaseAlt [Id]

RHS of a case-alternative with the variables bound by the pattern on the LHS

CaseScrut

Subject of a case-decomposition

CastBody

Body of a Cast

Instances
Eq CoreContext Source # 
Instance details
Show CoreContext Source # 
Instance details

data RewriteState extra Source #

State of a rewriting session

Constructors

RewriteState 

Fields

Instances
MonadState (RewriteState extra) (RewriteMonad extra) Source # 
Instance details

Methods

get :: RewriteMonad extra (RewriteState extra) #

put :: RewriteState extra -> RewriteMonad extra () #

state :: (RewriteState extra -> (a, RewriteState extra)) -> RewriteMonad extra a #

uniqSupply :: forall extra. Lens' (RewriteState extra) Supply Source #

transformCounter :: forall extra. Lens' (RewriteState extra) Int Source #

nameCounter :: forall extra. Lens' (RewriteState extra) Int Source #

extra :: forall extra extra. Lens (RewriteState extra) (RewriteState extra) extra extra Source #

curFun :: forall extra. Lens' (RewriteState extra) (TmName, SrcSpan) Source #

bindings :: forall extra. Lens' (RewriteState extra) BindingMap Source #

data RewriteEnv Source #

Read-only environment of a rewriting session

Constructors

RewriteEnv 

Fields

Instances
MonadReader RewriteEnv (RewriteMonad extra) Source # 
Instance details

Methods

ask :: RewriteMonad extra RewriteEnv #

local :: (RewriteEnv -> RewriteEnv) -> RewriteMonad extra a -> RewriteMonad extra a #

reader :: (RewriteEnv -> a) -> RewriteMonad extra a #

newtype RewriteMonad extra a Source #

Monad that keeps track how many transformations have been applied and can generate fresh variables and unique identifiers. In addition, it keeps track if a transformation/rewrite has been successfully applied.

Constructors

R 

Fields

Instances
MonadWriter Any (RewriteMonad extra) Source # 
Instance details

Methods

writer :: (a, Any) -> RewriteMonad extra a #

tell :: Any -> RewriteMonad extra () #

listen :: RewriteMonad extra a -> RewriteMonad extra (a, Any) #

pass :: RewriteMonad extra (a, Any -> Any) -> RewriteMonad extra a #

MonadReader RewriteEnv (RewriteMonad extra) Source # 
Instance details

Methods

ask :: RewriteMonad extra RewriteEnv #

local :: (RewriteEnv -> RewriteEnv) -> RewriteMonad extra a -> RewriteMonad extra a #

reader :: (RewriteEnv -> a) -> RewriteMonad extra a #

Monad (RewriteMonad extra) Source # 
Instance details

Methods

(>>=) :: RewriteMonad extra a -> (a -> RewriteMonad extra b) -> RewriteMonad extra b #

(>>) :: RewriteMonad extra a -> RewriteMonad extra b -> RewriteMonad extra b #

return :: a -> RewriteMonad extra a #

fail :: String -> RewriteMonad extra a #

Functor (RewriteMonad extra) Source # 
Instance details

Methods

fmap :: (a -> b) -> RewriteMonad extra a -> RewriteMonad extra b #

(<$) :: a -> RewriteMonad extra b -> RewriteMonad extra a #

MonadFix (RewriteMonad extra) Source # 
Instance details

Methods

mfix :: (a -> RewriteMonad extra a) -> RewriteMonad extra a #

Applicative (RewriteMonad extra) Source # 
Instance details

Methods

pure :: a -> RewriteMonad extra a #

(<*>) :: RewriteMonad extra (a -> b) -> RewriteMonad extra a -> RewriteMonad extra b #

liftA2 :: (a -> b -> c) -> RewriteMonad extra a -> RewriteMonad extra b -> RewriteMonad extra c #

(*>) :: RewriteMonad extra a -> RewriteMonad extra b -> RewriteMonad extra b #

(<*) :: RewriteMonad extra a -> RewriteMonad extra b -> RewriteMonad extra a #

Fresh (RewriteMonad extra) Source # 
Instance details

Methods

fresh :: Name a -> RewriteMonad extra (Name a)

MonadUnique (RewriteMonad extra) Source # 
Instance details
MonadState (RewriteState extra) (RewriteMonad extra) Source # 
Instance details

Methods

get :: RewriteMonad extra (RewriteState extra) #

put :: RewriteState extra -> RewriteMonad extra () #

state :: (RewriteState extra -> (a, RewriteState extra)) -> RewriteMonad extra a #

type Transform m = [CoreContext] -> Term -> m Term Source #

Monadic action that transforms a term given a certain context

type Rewrite extra = Transform (RewriteMonad extra) Source #

A Transform action in the context of the RewriteMonad