| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Futhark.Representation.AST.Attributes.Scope
Contents
Description
This module defines the concept of a type environment as a
mapping from variable names to Types. Convenience facilities are
also provided to communicate that some monad or applicative functor
maintains type information.
Synopsis
- class (Applicative m, Annotations lore) => HasScope lore m | m -> lore where
- lookupType :: VName -> m Type
- lookupInfo :: VName -> m (NameInfo lore)
- askScope :: m (Scope lore)
- asksScope :: (Scope lore -> a) -> m a
- data NameInfo lore
- = LetInfo (LetAttr lore)
- | FParamInfo (FParamAttr lore)
- | LParamInfo (LParamAttr lore)
- | IndexInfo IntType
- class (HasScope lore m, Monad m) => LocalScope lore m where
- localScope :: Scope lore -> m a -> m a
- type Scope lore = Map VName (NameInfo lore)
- class Scoped lore a | a -> lore where
- inScopeOf :: (Scoped lore a, LocalScope lore m) => a -> m b -> m b
- scopeOfLParams :: LParamAttr lore ~ attr => [ParamT attr] -> Scope lore
- scopeOfFParams :: FParamAttr lore ~ attr => [ParamT attr] -> Scope lore
- scopeOfPattern :: LetAttr lore ~ attr => PatternT attr -> Scope lore
- scopeOfPatElem :: LetAttr lore ~ attr => PatElemT attr -> Scope lore
- type SameScope lore1 lore2 = (LetAttr lore1 ~ LetAttr lore2, FParamAttr lore1 ~ FParamAttr lore2, LParamAttr lore1 ~ LParamAttr lore2)
- castScope :: SameScope fromlore tolore => Scope fromlore -> Scope tolore
- castNameInfo :: SameScope fromlore tolore => NameInfo fromlore -> NameInfo tolore
- data ExtendedScope lore m a
- extendedScope :: ExtendedScope lore m a -> Scope lore -> m a
Documentation
class (Applicative m, Annotations lore) => HasScope lore m | m -> lore where Source #
The class of applicative functors (or more common in practice:
monads) that permit the lookup of variable types. A default method
for lookupType exists, which is sufficient (if not always
maximally efficient, and using error to fail) when askScope
is defined.
Minimal complete definition
Methods
lookupType :: VName -> m Type Source #
Return the type of the given variable, or fail if it is not in the type environment.
lookupInfo :: VName -> m (NameInfo lore) Source #
Return the info of the given variable, or fail if it is not in the type environment.
askScope :: m (Scope lore) Source #
Return the type environment contained in the applicative functor.
asksScope :: (Scope lore -> a) -> m a Source #
Return the result of applying some function to the type environment.
Instances
How some name in scope was bound.
Constructors
| LetInfo (LetAttr lore) | |
| FParamInfo (FParamAttr lore) | |
| LParamInfo (LParamAttr lore) | |
| IndexInfo IntType |
Instances
class (HasScope lore m, Monad m) => LocalScope lore m where Source #
The class of monads that not only provide a Scope, but also
the ability to locally extend it. A Reader containing a
Scope is the prototypical example of such a monad.
Methods
localScope :: Scope lore -> m a -> m a Source #
Run a computation with an extended type environment. Note that this is intended to *add* to the current type environment, it does not replace it.
Instances
type Scope lore = Map VName (NameInfo lore) Source #
A scope is a mapping from variable names to information about that name.
class Scoped lore a | a -> lore where Source #
The class of things that can provide a scope. There is no
overarching rule for what this means. For a Stm, it is the
corresponding pattern. For a LambdaT, is is the parameters
(including index).
Instances
| Scoped Kernels LoopNesting Source # | |
Defined in Futhark.Pass.ExtractKernels.Distribution | |
| Scoped lore (Lambda lore) Source # | |
| Scoped lore (LoopForm lore) Source # | |
| Scoped lore (FunDef lore) Source # | |
| Scoped lore (Stm lore) Source # | |
| Scoped lore (Stms lore) Source # | |
| Scoped lore a => Scoped lore [a] Source # | |
Defined in Futhark.Representation.AST.Attributes.Scope | |
| Scoped lore (GroupStreamLambda lore) Source # | |
Defined in Futhark.Representation.Kernels.KernelExp Methods scopeOf :: GroupStreamLambda lore -> Scope lore Source # | |
| Scoped lore (VName, NameInfo lore) Source # | |
inScopeOf :: (Scoped lore a, LocalScope lore m) => a -> m b -> m b Source #
scopeOfLParams :: LParamAttr lore ~ attr => [ParamT attr] -> Scope lore Source #
scopeOfFParams :: FParamAttr lore ~ attr => [ParamT attr] -> Scope lore Source #
type SameScope lore1 lore2 = (LetAttr lore1 ~ LetAttr lore2, FParamAttr lore1 ~ FParamAttr lore2, LParamAttr lore1 ~ LParamAttr lore2) Source #
castScope :: SameScope fromlore tolore => Scope fromlore -> Scope tolore Source #
If two scopes are really the same, then you can convert one to the other.
Extended type environment
data ExtendedScope lore m a Source #
A monad transformer that carries around an extended Scope.
Its lookupType method will first look in the extended Scope,
and then use the lookupType method of the underlying monad.
Instances
extendedScope :: ExtendedScope lore m a -> Scope lore -> m a Source #
Run a computation in the extended type environment.