futhark-0.11.0: An optimising compiler for a functional, array-oriented language.

Safe HaskellNone
LanguageHaskell2010

Futhark.Binder

Contents

Description

This module defines a convenience monad/typeclass for creating normalised programs.

Synopsis

A concrete MonadBinder monad.

data BinderT lore m a Source #

Instances
MonadWriter w m => MonadWriter w (BinderT lore m) Source # 
Instance details

Defined in Futhark.Binder

Methods

writer :: (a, w) -> BinderT lore m a #

tell :: w -> BinderT lore m () #

listen :: BinderT lore m a -> BinderT lore m (a, w) #

pass :: BinderT lore m (a, w -> w) -> BinderT lore m a #

MonadState s m => MonadState s (BinderT lore m) Source # 
Instance details

Defined in Futhark.Binder

Methods

get :: BinderT lore m s #

put :: s -> BinderT lore m () #

state :: (s -> (a, s)) -> BinderT lore m a #

MonadReader r m => MonadReader r (BinderT lore m) Source # 
Instance details

Defined in Futhark.Binder

Methods

ask :: BinderT lore m r #

local :: (r -> r) -> BinderT lore m a -> BinderT lore m a #

reader :: (r -> a) -> BinderT lore m a #

MonadError e m => MonadError e (BinderT lore m) Source # 
Instance details

Defined in Futhark.Binder

Methods

throwError :: e -> BinderT lore m a #

catchError :: BinderT lore m a -> (e -> BinderT lore m a) -> BinderT lore m a #

(Attributes lore, Monad m) => LocalScope lore (BinderT lore m) Source # 
Instance details

Defined in Futhark.Binder

Methods

localScope :: Scope lore -> BinderT lore m a -> BinderT lore m a Source #

(Attributes lore, Monad m) => HasScope lore (BinderT lore m) Source # 
Instance details

Defined in Futhark.Binder

Methods

lookupType :: VName -> BinderT lore m Type Source #

lookupInfo :: VName -> BinderT lore m (NameInfo lore) Source #

askScope :: BinderT lore m (Scope lore) Source #

asksScope :: (Scope lore -> a) -> BinderT lore m a Source #

MonadTrans (BinderT lore) Source # 
Instance details

Defined in Futhark.Binder

Methods

lift :: Monad m => m a -> BinderT lore m a #

Monad m => Monad (BinderT lore m) Source # 
Instance details

Defined in Futhark.Binder

Methods

(>>=) :: BinderT lore m a -> (a -> BinderT lore m b) -> BinderT lore m b #

(>>) :: BinderT lore m a -> BinderT lore m b -> BinderT lore m b #

return :: a -> BinderT lore m a #

fail :: String -> BinderT lore m a #

Functor m => Functor (BinderT lore m) Source # 
Instance details

Defined in Futhark.Binder

Methods

fmap :: (a -> b) -> BinderT lore m a -> BinderT lore m b #

(<$) :: a -> BinderT lore m b -> BinderT lore m a #

Monad m => MonadFail (BinderT lore m) Source # 
Instance details

Defined in Futhark.Binder

Methods

fail :: String -> BinderT lore m a #

Monad m => Applicative (BinderT lore m) Source # 
Instance details

Defined in Futhark.Binder

Methods

pure :: a -> BinderT lore m a #

(<*>) :: BinderT lore m (a -> b) -> BinderT lore m a -> BinderT lore m b #

liftA2 :: (a -> b -> c) -> BinderT lore m a -> BinderT lore m b -> BinderT lore m c #

(*>) :: BinderT lore m a -> BinderT lore m b -> BinderT lore m b #

(<*) :: BinderT lore m a -> BinderT lore m b -> BinderT lore m a #

MonadFreshNames m => MonadFreshNames (BinderT lore m) Source # 
Instance details

Defined in Futhark.Binder

(Attributes lore, MonadFreshNames m, BinderOps lore) => MonadBinder (BinderT lore m) Source # 
Instance details

Defined in Futhark.Binder

Associated Types

type Lore (BinderT lore m) :: Type Source #

Methods

mkExpAttrM :: Pattern (Lore (BinderT lore m)) -> Exp (Lore (BinderT lore m)) -> BinderT lore m (ExpAttr (Lore (BinderT lore m))) Source #

mkBodyM :: Stms (Lore (BinderT lore m)) -> Result -> BinderT lore m (Body (Lore (BinderT lore m))) Source #

mkLetNamesM :: [VName] -> Exp (Lore (BinderT lore m)) -> BinderT lore m (Stm (Lore (BinderT lore m))) Source #

addStm :: Stm (Lore (BinderT lore m)) -> BinderT lore m () Source #

addStms :: Stms (Lore (BinderT lore m)) -> BinderT lore m () Source #

collectStms :: BinderT lore m a -> BinderT lore m (a, Stms (Lore (BinderT lore m))) Source #

certifying :: Certificates -> BinderT lore m a -> BinderT lore m a Source #

type Lore (BinderT lore m) Source # 
Instance details

Defined in Futhark.Binder

type Lore (BinderT lore m) = lore

runBinderT :: MonadFreshNames m => BinderT lore m a -> Scope lore -> m (a, Stms lore) Source #

class Attributes lore => BinderOps lore where Source #

Methods

mkExpAttrB :: (MonadBinder m, Lore m ~ lore) => Pattern lore -> Exp lore -> m (ExpAttr lore) Source #

mkBodyB :: (MonadBinder m, Lore m ~ lore) => Stms lore -> Result -> m (Body lore) Source #

mkLetNamesB :: (MonadBinder m, Lore m ~ lore) => [VName] -> Exp lore -> m (Stm lore) Source #

Instances
BinderOps SOACS Source # 
Instance details

Defined in Futhark.Representation.SOACS

BinderOps InKernel Source # 
Instance details

Defined in Futhark.Representation.Kernels

BinderOps Kernels Source # 
Instance details

Defined in Futhark.Representation.Kernels

BinderOps ExplicitMemory Source # 
Instance details

Defined in Futhark.Pass.ExplicitAllocations

(Attributes (Aliases lore), Bindable (Aliases lore)) => BinderOps (Aliases lore) Source # 
Instance details

Defined in Futhark.Representation.Aliases

Methods

mkExpAttrB :: (MonadBinder m, Lore m ~ Aliases lore) => Pattern (Aliases lore) -> Exp (Aliases lore) -> m (ExpAttr (Aliases lore)) Source #

mkBodyB :: (MonadBinder m, Lore m ~ Aliases lore) => Stms (Aliases lore) -> Result -> m (Body (Aliases lore)) Source #

mkLetNamesB :: (MonadBinder m, Lore m ~ Aliases lore) => [VName] -> Exp (Aliases lore) -> m (Stm (Aliases lore)) Source #

BinderOps (Wise SOACS) Source # 
Instance details

Defined in Futhark.Representation.SOACS.Simplify

BinderOps (Wise InKernel) Source # 
Instance details

Defined in Futhark.Representation.Kernels.Simplify

BinderOps (Wise Kernels) Source # 
Instance details

Defined in Futhark.Representation.Kernels.Simplify

BinderOps (Wise ExplicitMemory) Source # 
Instance details

Defined in Futhark.Pass.ExplicitAllocations

type Binder lore = BinderT lore (State VNameSource) Source #

runBinder :: (MonadFreshNames m, HasScope somelore m, SameScope somelore lore) => Binder lore a -> m (a, Stms lore) Source #

runBinder_ :: (MonadFreshNames m, HasScope somelore m, SameScope somelore lore) => Binder lore a -> m (Stms lore) Source #

Like runBinder, but throw away the result and just return the added bindings.

joinBinder :: MonadBinder m => Binder (Lore m) a -> m a Source #

As runBinder, but uses addStm to add the returned bindings to the surrounding monad.

runBodyBinder :: (Bindable lore, MonadFreshNames m, HasScope somelore m, SameScope somelore lore) => Binder lore (Body lore) -> m (Body lore) Source #

Non-class interface

addBinderStms :: Monad m => Stms lore -> BinderT lore m () Source #

collectBinderStms :: Monad m => BinderT lore m a -> BinderT lore m (a, Stms lore) Source #

The MonadBinder typeclass