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

Gibbon.Common

Description

Utilities and common types.

Synopsis

Variables

newtype Var Source #

Constructors

Var Symbol 

Instances

Instances details
Out Var Source # 
Instance details

Defined in Gibbon.Common

Methods

docPrec :: Int -> Var -> Doc Source #

doc :: Var -> Doc Source #

docList :: [Var] -> Doc Source #

IsString Var Source # 
Instance details

Defined in Gibbon.Common

Read Var Source # 
Instance details

Defined in Gibbon.Common

Show Var Source # 
Instance details

Defined in Gibbon.Common

NFData Var Source # 
Instance details

Defined in Gibbon.Common

Methods

rnf :: Var -> () Source #

Eq Var Source # 
Instance details

Defined in Gibbon.Common

Methods

(==) :: Var -> Var -> Bool Source #

(/=) :: Var -> Var -> Bool Source #

Ord Var Source # 
Instance details

Defined in Gibbon.Common

Methods

compare :: Var -> Var -> Ordering Source #

(<) :: Var -> Var -> Bool Source #

(<=) :: Var -> Var -> Bool Source #

(>) :: Var -> Var -> Bool Source #

(>=) :: Var -> Var -> Bool Source #

max :: Var -> Var -> Var Source #

min :: Var -> Var -> Var Source #

FreeVars LocExp Source # 
Instance details

Defined in Gibbon.L2.Syntax

FunctionTy Ty2 Source #

Function types know about locations and traversal effects.

Instance details

Defined in Gibbon.L2.Syntax

Associated Types

type ArrowTy Ty2 Source #

Renamable Var Source # 
Instance details

Defined in Gibbon.Language

Methods

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

Pretty Var Source # 
Instance details

Defined in Gibbon.Pretty

ToIdent Var Source # 
Instance details

Defined in Gibbon.Common

Methods

toIdent :: Var -> SrcLoc -> Id Source #

Interp Store Exp2 Source # 
Instance details

Defined in Gibbon.L2.Interp

InterpProg Store Exp2 Source # 
Instance details

Defined in Gibbon.L2.Interp

InterpExt Store Exp2 (E2Ext LocVar Ty2) Source # 
Instance details

Defined in Gibbon.L2.Interp

Out (ArrowTy2 Ty2) Source # 
Instance details

Defined in Gibbon.L2.Syntax

FreeVars a => FreeVars (TyEnv a) Source # 
Instance details

Defined in Gibbon.L0.Typecheck

Methods

gFreeVars :: TyEnv a -> Set Var Source #

Pretty [Var] Source # 
Instance details

Defined in Gibbon.Pretty

Typeable (PreExp E2Ext LocVar (UrTy LocVar)) Source #

The gRecoverType instance defined in Language.Syntax is incorrect for L2. For the AppE case, it'll just return the type with with the function was defined. However, we want the recovered type to have the locations actually used at the callsites! For example,

add1 :: Tree a -> Tree b add1 = _

... (add1 [loc1, loc2] tr1) ..

in this case, we want the type of (add1 tr1) to be (Tree loc2) and NOT (Tree b). We have to do something similar for variables bound by a pattern match.

Instance details

Defined in Gibbon.L2.Syntax

type ArrowTy Ty2 Source # 
Instance details

Defined in Gibbon.L2.Syntax

type LocVar = Var Source #

Abstract location variables.

type RegVar = Var Source #

Abstract region variables.

varAppend :: Var -> Var -> Var Source #

String concatenation on variables.

cleanFunName :: Var -> Var Source #

Filter out non-C compatible characters. This naively assumes it will get no conflicts. Which may be correct if function names were gensym'd also....

data TyVar Source #

Type variables that enable polymorphism.

Instances

Instances details
Out TyVar Source # 
Instance details

Defined in Gibbon.Common

Generic TyVar Source # 
Instance details

Defined in Gibbon.Common

Associated Types

type Rep TyVar :: Type -> Type Source #

Methods

from :: TyVar -> Rep TyVar x Source #

to :: Rep TyVar x -> TyVar Source #

Read TyVar Source # 
Instance details

Defined in Gibbon.Common

Show TyVar Source # 
Instance details

Defined in Gibbon.Common

NFData TyVar Source # 
Instance details

Defined in Gibbon.Common

Methods

rnf :: TyVar -> () Source #

Eq TyVar Source # 
Instance details

Defined in Gibbon.Common

Methods

(==) :: TyVar -> TyVar -> Bool Source #

(/=) :: TyVar -> TyVar -> Bool Source #

Ord TyVar Source # 
Instance details

Defined in Gibbon.Common

Renamable TyVar Source # 
Instance details

Defined in Gibbon.L0.Syntax

Methods

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

Pretty TyVar Source # 
Instance details

Defined in Gibbon.Pretty

type Rep TyVar Source # 
Instance details

Defined in Gibbon.Common

data Symbol Source #

Instances

Instances details
IsString Symbol Source # 
Instance details

Defined in Gibbon.Common

Read Symbol Source # 
Instance details

Defined in Gibbon.Common

Show Symbol Source # 
Instance details

Defined in Gibbon.Common

Eq Symbol Source # 
Instance details

Defined in Gibbon.Common

Ord Symbol Source # 
Instance details

Defined in Gibbon.Common

Gensym monad

data SyM a Source #

Instances

Instances details
MonadFail SyM Source # 
Instance details

Defined in Gibbon.Common

Methods

fail :: String -> SyM a Source #

Applicative SyM Source # 
Instance details

Defined in Gibbon.Common

Methods

pure :: a -> SyM a Source #

(<*>) :: SyM (a -> b) -> SyM a -> SyM b Source #

liftA2 :: (a -> b -> c) -> SyM a -> SyM b -> SyM c Source #

(*>) :: SyM a -> SyM b -> SyM b Source #

(<*) :: SyM a -> SyM b -> SyM a Source #

Functor SyM Source # 
Instance details

Defined in Gibbon.Common

Methods

fmap :: (a -> b) -> SyM a -> SyM b Source #

(<$) :: a -> SyM b -> SyM a Source #

Monad SyM Source # 
Instance details

Defined in Gibbon.Common

Methods

(>>=) :: SyM a -> (a -> SyM b) -> SyM b Source #

(>>) :: SyM a -> SyM b -> SyM b Source #

return :: a -> SyM a Source #

MonadState Int SyM Source # 
Instance details

Defined in Gibbon.Common

Methods

get :: SyM Int Source #

put :: Int -> SyM () Source #

state :: (Int -> (a, Int)) -> SyM a Source #

gensym :: MonadState Int m => Var -> m Var Source #

Generate a unique symbol by attaching a numeric suffix.

genLetter :: MonadState Int m => m Var Source #

An infinite alphabet generator: a,b, ... ,z,a0, ...

newUniq :: MonadState Int m => m Int Source #

A fresh int.

runSyM :: Int -> SyM a -> (a, Int) Source #

PassM monad

data PassM a Source #

The monad used by core Gibbon passes to access Config and other shared state.

Instances

Instances details
MonadFail PassM Source # 
Instance details

Defined in Gibbon.Common

Methods

fail :: String -> PassM a Source #

Applicative PassM Source # 
Instance details

Defined in Gibbon.Common

Methods

pure :: a -> PassM a Source #

(<*>) :: PassM (a -> b) -> PassM a -> PassM b Source #

liftA2 :: (a -> b -> c) -> PassM a -> PassM b -> PassM c Source #

(*>) :: PassM a -> PassM b -> PassM b Source #

(<*) :: PassM a -> PassM b -> PassM a Source #

Functor PassM Source # 
Instance details

Defined in Gibbon.Common

Methods

fmap :: (a -> b) -> PassM a -> PassM b Source #

(<$) :: a -> PassM b -> PassM a Source #

Monad PassM Source # 
Instance details

Defined in Gibbon.Common

Methods

(>>=) :: PassM a -> (a -> PassM b) -> PassM b Source #

(>>) :: PassM a -> PassM b -> PassM b Source #

return :: a -> PassM a Source #

MonadReader Config PassM Source # 
Instance details

Defined in Gibbon.Common

Methods

ask :: PassM Config Source #

local :: (Config -> Config) -> PassM a -> PassM a Source #

reader :: (Config -> a) -> PassM a Source #

MonadState Int PassM Source # 
Instance details

Defined in Gibbon.Common

Methods

get :: PassM Int Source #

put :: Int -> PassM () Source #

state :: (Int -> (a, Int)) -> PassM a Source #

runPassM :: Config -> Int -> PassM a -> (a, Int) Source #

defaultRunPassM :: PassM a -> (a, Int) Source #

A convenient wrapper over runPassM.

defaultPackedRunPassM :: PassM a -> (a, Int) Source #

A convenient wrapper over runPassM for running passes in packed mode.

Gibbon configuration

data Config Source #

Overall configuration of the compiler, as determined by command line arguments and possible environment variables.

Constructors

Config 

Fields

Instances

Instances details
Read Config Source # 
Instance details

Defined in Gibbon.Common

Show Config Source # 
Instance details

Defined in Gibbon.Common

Eq Config Source # 
Instance details

Defined in Gibbon.Common

Ord Config Source # 
Instance details

Defined in Gibbon.Common

MonadReader Config PassM Source # 
Instance details

Defined in Gibbon.Common

Methods

ask :: PassM Config Source #

local :: (Config -> Config) -> PassM a -> PassM a Source #

reader :: (Config -> a) -> PassM a Source #

data Input Source #

What input format to expect on disk.

Constructors

Haskell 
SExpr 
Unspecified 

Instances

Instances details
Bounded Input Source # 
Instance details

Defined in Gibbon.Common

Enum Input Source # 
Instance details

Defined in Gibbon.Common

Read Input Source # 
Instance details

Defined in Gibbon.Common

Show Input Source # 
Instance details

Defined in Gibbon.Common

Eq Input Source # 
Instance details

Defined in Gibbon.Common

Methods

(==) :: Input -> Input -> Bool Source #

(/=) :: Input -> Input -> Bool Source #

Ord Input Source # 
Instance details

Defined in Gibbon.Common

data Mode Source #

How far to run the compiler/interpreter.

Constructors

ToParse

Parse and then stop

ToC

Compile to C

ToExe

Compile to C then build a binary.

RunExe

Compile to executable then run.

Interp2

Interp late in the compiler pipeline.

Interp1

Interp early.

ToMPL

Compile to SML (mlton dialect)

ToMPLExe

Compile to SML & compile with MPL

RunMPL

Compile to SML & compile with MPL & run

Bench Var

Benchmark a particular function applied to the packed data within an input file.

BenchInput FilePath

Hardcode the input file to the benchmark in the C code.

Instances

Instances details
Read Mode Source # 
Instance details

Defined in Gibbon.Common

Show Mode Source # 
Instance details

Defined in Gibbon.Common

Eq Mode Source # 
Instance details

Defined in Gibbon.Common

Methods

(==) :: Mode -> Mode -> Bool Source #

(/=) :: Mode -> Mode -> Bool Source #

Ord Mode Source # 
Instance details

Defined in Gibbon.Common

data Backend Source #

Compilation backend used

Constructors

C 
LLVM 

data RunConfig Source #

Runtime configuration for executing interpreters.

Constructors

RunConfig 

Fields

getRunConfig :: [String] -> IO RunConfig Source #

We currently use the hacky approach of using env vars OR command line args to set the two universal benchmark params: SIZE and ITERS.

This takes extra, optional command line args [Size, Iters] provided after the file to process on the command line. If these are not present it

Misc helpers

data SSModality Source #

Constructors

Read 
Write 

Instances

Instances details
Out SSModality Source # 
Instance details

Defined in Gibbon.Common

Generic SSModality Source # 
Instance details

Defined in Gibbon.Common

Associated Types

type Rep SSModality :: Type -> Type Source #

Read SSModality Source # 
Instance details

Defined in Gibbon.Common

Show SSModality Source # 
Instance details

Defined in Gibbon.Common

NFData SSModality Source # 
Instance details

Defined in Gibbon.Common

Methods

rnf :: SSModality -> () Source #

Eq SSModality Source # 
Instance details

Defined in Gibbon.Common

Ord SSModality Source # 
Instance details

Defined in Gibbon.Common

type Rep SSModality Source # 
Instance details

Defined in Gibbon.Common

type Rep SSModality = D1 ('MetaData "SSModality" "Gibbon.Common" "gibbon-0.3-inplace" 'False) (C1 ('MetaCons "Read" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Write" 'PrefixI 'False) (U1 :: Type -> Type))

(#) :: (Ord a, Out a, Out b, Show a, HasCallStack) => Map a b -> a -> b Source #

(!!!) :: (Out a, HasCallStack) => [a] -> Int -> a Source #

fragileZip :: (Show a, Show b, HasCallStack) => [a] -> [b] -> [(a, b)] Source #

fragileZip' :: (Show a, Show b, HasCallStack) => [a] -> [b] -> String -> [(a, b)] Source #

Like fragileZip, but takes a custom error message.

sdoc :: Out a => a -> String Source #

Handy combination of show and doc

ndoc :: Out a => a -> String Source #

Like sdoc but inserts newline if it is longish.

abbrv :: Out a => Int -> a -> String Source #

Like ndoc/sdoc but cut it off with "..." after a char limit.

lookup3 :: (Eq k, Show k, Show a, Show b) => k -> [(k, a, b)] -> (k, a, b) Source #

fst3 :: (a, b, c) -> a Source #

snd3 :: (a, b, c) -> b Source #

thd3 :: (a, b, c) -> c Source #

cataM :: (Monad m, Traversable (Base t), Recursive t) => (Base t a -> m a) -> t -> m a Source #

Debugging/logging:

dbgLvl :: Int Source #

Debugging flag shared by all modules. This is activated by setting the environment variable DEBUG=1..5

dbgPrint :: Int -> String -> IO () Source #

Print if the debug level is at or above a threshold.

dbgTrace :: Int -> String -> a -> a Source #

Conditional version of Debug.Trace.trace

dbgTraceIt :: String -> a -> a Source #

Yo, trace this msg.

minChatLvl :: Int Source #

We should not create chatter below this level. DEBUG=1 is used for assertions only, not chatter.

internalError :: HasCallStack => String -> a Source #

An error that is OUR FAULT, i.e. an internal bug in the compiler.

dumpIfSet :: Config -> DebugFlag -> String -> IO () Source #

Dump some output if the flag is set. Otherwise, do nothing.

Establish conventions for the output of #lang gibbon:

truePrinted :: String Source #

For now this is designed to match the Racket output of "#lang gibbon" which itself should change once we implement a custom printer.

Orphan instances

(Out k, Out v) => Out (Map k v) Source # 
Instance details

Methods

docPrec :: Int -> Map k v -> Doc Source #

doc :: Map k v -> Doc Source #

docList :: [Map k v] -> Doc Source #