ghc-8.2.1.20171108: The GHC API

Safe HaskellNone
LanguageHaskell2010

Vectorise.Monad.Base

Contents

Description

The Vectorisation monad.

Synopsis

The Vectorisation Monad

data VResult a Source #

Vectorisation can either succeed with new envionment and a value, or return with failure (including a description of the reason for failure).

Constructors

Yes GlobalEnv LocalEnv a 
No SDoc 

newtype VM a Source #

Constructors

VM 

Fields

Instances

Monad VM # 

Methods

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

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

return :: a -> VM a Source #

fail :: String -> VM a Source #

Functor VM # 

Methods

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

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

Applicative VM # 

Methods

pure :: a -> VM a Source #

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

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

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

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

MonadIO VM # 

Methods

liftIO :: IO a -> VM a Source #

HasDynFlags VM # 

Lifting

liftDs :: DsM a -> VM a Source #

Lift a desugaring computation into the vectorisation monad.

Error Handling

cantVectorise :: DynFlags -> String -> SDoc -> a Source #

Throw a pgmError saying we can't vectorise something.

maybeCantVectorise :: DynFlags -> String -> SDoc -> Maybe a -> a Source #

Like fromJust, but pgmError on Nothing.

maybeCantVectoriseM :: (Monad m, HasDynFlags m) => String -> SDoc -> m (Maybe a) -> m a Source #

Like maybeCantVectorise but in a Monad.

Debugging

emitVt :: String -> SDoc -> VM () Source #

Output a trace message if -ddump-vt-trace is active.

traceVt :: String -> SDoc -> VM () Source #

Output a trace message if -ddump-vt-trace is active.

dumpOptVt :: DumpFlag -> String -> SDoc -> VM () Source #

Dump the given program conditionally.

dumpVt :: String -> SDoc -> VM () Source #

Dump the given program unconditionally.

Control

noV :: SDoc -> VM a Source #

Return some result saying we've failed.

traceNoV :: String -> SDoc -> VM a Source #

Like traceNoV but also emit some trace message to stderr.

ensureV :: SDoc -> Bool -> VM () Source #

If True then carry on, otherwise fail.

traceEnsureV :: String -> SDoc -> Bool -> VM () Source #

Like ensureV but if we fail then emit some trace message to stderr.

onlyIfV :: SDoc -> Bool -> VM a -> VM a Source #

If True then return the first argument, otherwise fail.

tryV :: VM a -> VM (Maybe a) Source #

Try some vectorisation computaton.

If it succeeds then return Just the result; otherwise, return Nothing without emitting a failure message.

tryErrV :: VM a -> VM (Maybe a) Source #

Try some vectorisation computaton.

If it succeeds then return Just the result; otherwise, return Nothing after emitting a failure message.

maybeV :: SDoc -> VM (Maybe a) -> VM a Source #

If Just then return the value, otherwise fail.

traceMaybeV :: String -> SDoc -> VM (Maybe a) -> VM a Source #

Like maybeV but emit a message to stderr if we fail.

orElseV :: VM a -> VM a -> VM a Source #

Try the first computation,

  • if it succeeds then take the returned value,
  • if it fails then run the second computation instead without emitting a failure message.

orElseErrV :: VM a -> VM a -> VM a Source #

Try the first computation,

  • if it succeeds then take the returned value,
  • if it fails then run the second computation instead while emitting a failure message.

fixV :: (a -> VM a) -> VM a Source #

Fixpoint in the vectorisation monad.