gibbon-0.3: A compiler for operating on serialized data
Safe HaskellSafe-Inferred
LanguageHaskell2010

Gibbon.Language

Synopsis

Documentation

Helpers operating on expressions

mapExt :: (e1 l d -> e2 l d) -> PreExp e1 l d -> PreExp e2 l d Source #

Apply a function to the extension points only.

mapLocs :: (e l2 d -> e l2 d) -> PreExp e l2 d -> PreExp e l2 d Source #

Apply a function to the locations only.

mapExprs :: (e -> e) -> Prog e -> Prog e Source #

Transform the expressions within a program.

mapMExprs :: Monad m => (e -> m e) -> Prog e -> m (Prog e) Source #

Monadic mapExprs.

visitExp :: forall l1 l2 e1 e2 d1 d2. (l1 -> l2) -> (e1 l1 d1 -> e2 l2 d2) -> (d1 -> d2) -> PreExp e1 l1 d1 -> PreExp e2 l2 d2 Source #

Apply a function to the locations, extensions, and binder-decorations, respectively.

subst :: HasSubstitutable e l d => Var -> PreExp e l d -> PreExp e l d -> PreExp e l d Source #

Substitute an expression in place of a variable.

substE :: HasSubstitutable e l d => PreExp e l d -> PreExp e l d -> PreExp e l d -> PreExp e l d Source #

Expensive subst that looks for a whole matching sub-EXPRESSION. If the old expression is a variable, this still avoids going under binder.

hasTimeIt :: PreExp e l d -> Bool Source #

Does the expression contain a TimeIt form?

hasSpawns :: PreExp e l d -> Bool Source #

Does the expression contain a SpawnE form?

projNonFirst :: (Out l, Out d, Out (e l d)) => Int -> PreExp e l d -> PreExp e l d Source #

Project something which had better not be the first thing in a tuple.

mkProj :: Int -> PreExp e l d -> PreExp e l d Source #

Smart constructor that immediately destroys products if it can: Does NOT avoid single-element tuples.

mkProd :: [PreExp e l d] -> PreExp e l d Source #

Make a product type while avoiding unary products.

mkLets :: [(Var, [loc], dec, PreExp ext loc dec)] -> PreExp ext loc dec -> PreExp ext loc dec Source #

Make a nested series of lets.

flatLets :: [(Var, [l], d, PreExp e l d)] -> PreExp e l d -> PreExp e l d Source #

Alternative version of L1.mkLets that also flattens

tuplizeRefs :: Var -> [Var] -> [d] -> PreExp e l d -> PreExp e l d Source #

Helpers operating on types

mkProdTy :: [UrTy a] -> UrTy a Source #

Same as mkProd, at the type level

projTy :: Out a => Int -> UrTy a -> UrTy a Source #

voidTy :: UrTy a Source #

A makeshift void type.

isProdTy :: UrTy a -> Bool Source #

Are values of this type tuples ?

isNestedProdTy :: UrTy a -> Bool Source #

Do values of this type contain nested tuples ?

isPackedTy :: UrTy a -> Bool Source #

Are values of this type Packed ?

hasPacked :: Show a => UrTy a -> Bool Source #

Do values of this type contain packed data?

sizeOfTy :: UrTy a -> Maybe Int Source #

Provide a size in bytes, if it is statically known.

primArgsTy :: Prim (UrTy a) -> [UrTy a] Source #

Type of the arguments for a primitive operation.

primRetTy :: Prim (UrTy a) -> UrTy a Source #

Return type for a primitive operation.

tyToDataCon :: Show a => UrTy a -> DataCon Source #

Get the data constructor type from a type, failing if it's not packed

isValidListElemTy :: UrTy a -> Bool Source #

Lists of scalars or flat products of scalars are allowed.

getPackedTys :: Show a => UrTy a -> [UrTy a] Source #

Get all packed types in a type.

Misc

assertTriv :: (HasCallStack, Expression e) => e -> a -> a Source #

Ensure that an expression is trivial.

assertTrivs :: (HasCallStack, Expression e) => [e] -> a -> a Source #

List version of assertTriv.

Orphan instances

Renamable Var Source # 
Instance details

Methods

gRename :: Map Var Var -> Var -> Var Source #

Renamable a => Renamable (UrTy a) Source # 
Instance details

Methods

gRename :: Map Var Var -> UrTy a -> UrTy a Source #

(Out l, Show l, Show d, Out d, Expression (e l d)) => Expression (PreExp e l d) Source # 
Instance details

Associated Types

type TyOf (PreExp e l d) Source #

type LocOf (PreExp e l d) Source #

Methods

isTrivial :: PreExp e l d -> Bool Source #

FreeVars (e l d) => FreeVars (PreExp e l d) Source #

Free data variables. Does not include function variables, which currently occupy a different namespace. Does not include location/region variables.

Instance details

Methods

gFreeVars :: PreExp e l d -> Set Var Source #

HasRenamable e l d => Renamable (PreExp e l d) Source # 
Instance details

Methods

gRename :: Map Var Var -> PreExp e l d -> PreExp e l d Source #

HasSubstitutable e l d => Substitutable (PreExp e l d) Source # 
Instance details

Methods

gSubst :: Var -> PreExp e l d -> PreExp e l d -> PreExp e l d Source #

gSubstE :: PreExp e l d -> PreExp e l d -> PreExp e l d -> PreExp e l d Source #

(Show (), Out (), TyOf (e () (UrTy ())) ~ TyOf (PreExp e () (UrTy ())), FunctionTy (UrTy ()), Typeable (e () (UrTy ()))) => Typeable (PreExp e () (UrTy ())) Source #

A Typeable instance for L1 and L3 (L2 defines it's own)

Instance details

Methods

gRecoverType :: DDefs (TyOf (PreExp e () (UrTy ()))) -> Env2 (TyOf (PreExp e () (UrTy ()))) -> PreExp e () (UrTy ()) -> TyOf (PreExp e () (UrTy ())) Source #