clash-lib-1.8.4: Clash: a functional hardware description language - As a library
Copyright(C) 2012-2016 University of Twente
LicenseBSD2 (see the file LICENSE)
MaintainerQBayLogic B.V. <devops@qbaylogic.com>
Safe HaskellNone
LanguageHaskell2010

Clash.Util

Description

Assortment of utility function used in the Clash library

Synopsis

Documentation

pprDebugAndThen :: (String -> a) -> Doc ann -> Doc ann -> a Source #

pprPanic :: String -> Doc ann -> a Source #

assertPprPanic :: HasCallStack => String -> Int -> Doc ann -> a Source #

pprTrace :: String -> Doc ann -> a -> a Source #

pprTraceDebug :: String -> Doc ann -> a -> a Source #

warnPprTrace Source #

Arguments

:: HasCallStack 
=> Bool

Trigger warning?

-> String

File name

-> Int

Line number

-> Doc ann

Message

-> a

Pass value (like trace)

-> a 

class Monad m => MonadUnique (m :: Type -> Type) where Source #

A class that can generate unique numbers

Methods

getUniqueM :: m Unique Source #

Get a new unique

Instances

Instances details
MonadUnique (RewriteMonad extra) Source # 
Instance details

Defined in Clash.Rewrite.Types

Monad m => MonadUnique (StateT Unique m) Source # 
Instance details

Defined in Clash.Util

curLoc :: Q Exp Source #

Create a TH expression that returns the a formatted string containing the name of the module curLoc is spliced into, and the line where it was spliced.

clogBase :: Integer -> Integer -> Maybe Int Source #

x y -> ceiling (logBase x y), x > 1 && y > 0

makeCached Source #

Arguments

:: (MonadState s m, Hashable k, Eq k) 
=> k

The key the action is associated with

-> Lens' s (HashMap k v)

The Lens to the HashMap that is the cache

-> m v

The action to cache

-> m v 

Cache the result of a monadic action

indexNote Source #

Arguments

:: HasCallStack 
=> String

Error message to display

-> [a]

List to index

-> Int

Index n

-> a

Error or element n

Unsafe indexing, return a custom error message when indexing fails

makeCachedU Source #

Arguments

:: (MonadState s m, Uniquable k) 
=> k

Key the action is associated with

-> Lens' s (UniqMap v)

Lens to the cache

-> m v

Action to cache

-> m v 

Cache the result of a monadic action using a UniqMap

namePat :: Name -> Q Pat Source #

Construct a string pattern match out of the given TemplateHaskell name

makeCachedO Source #

Arguments

:: (MonadState s m, Uniquable k) 
=> k

Key the action is associated with

-> Lens' s (OMap Unique v)

Lens to the cache

-> m v

Action to cache

-> m v 

Cache the result of a monadic action using a OMap

indexNote' Source #

Arguments

:: HasCallStack 
=> String

Error message to display

-> Int

Index n

-> [a]

List to index

-> a

Error or element n

Same as indexNote with last two arguments swapped

flogBase :: Integer -> Integer -> Maybe Int Source #

x y -> floor (logBase x y), x > 1 && y > 0

pkgIdFromTypeable :: Typeable a => a -> String Source #

Get the package id of the type of a value

>>> pkgIdFromTypeable (0 :: Unsigned 32)
"clash-prelude-...

orElses :: [Maybe a] -> Maybe a Source #

Left-biased choice on maybes

data SrcSpan Source #

Source Span

A SrcSpan identifies either a specific portion of a text file or a human-readable description of a location.

Instances

Instances details
Binary SrcSpan Source # 
Instance details

Defined in GHC.SrcLoc.Extra

PrettyPrec SrcSpan Source # 
Instance details

Defined in Clash.Core.Pretty

NFData SrcSpan 
Instance details

Defined in GHC.Types.SrcLoc

Methods

rnf :: SrcSpan -> () Source #

HasAnnotation SrcSpan 
Instance details

Defined in GHC.Parser.Annotation

HasLoc SrcSpan 
Instance details

Defined in GHC.Parser.Annotation

ToJson SrcSpan 
Instance details

Defined in GHC.Types.SrcLoc

Methods

json :: SrcSpan -> JsonDoc Source #

Outputable SrcSpan 
Instance details

Defined in GHC.Types.SrcLoc

Methods

ppr :: SrcSpan -> SDoc Source #

Data SrcSpan 
Instance details

Defined in GHC.Types.SrcLoc

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> SrcSpan -> c SrcSpan Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c SrcSpan Source #

toConstr :: SrcSpan -> Constr Source #

dataTypeOf :: SrcSpan -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c SrcSpan) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c SrcSpan) Source #

gmapT :: (forall b. Data b => b -> b) -> SrcSpan -> SrcSpan Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> SrcSpan -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> SrcSpan -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> SrcSpan -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> SrcSpan -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> SrcSpan -> m SrcSpan Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> SrcSpan -> m SrcSpan Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> SrcSpan -> m SrcSpan Source #

Generic SrcSpan Source # 
Instance details

Defined in GHC.SrcLoc.Extra

Associated Types

type Rep SrcSpan 
Instance details

Defined in GHC.SrcLoc.Extra

Show SrcSpan 
Instance details

Defined in GHC.Types.SrcLoc

Eq SrcSpan 
Instance details

Defined in GHC.Types.SrcLoc

Hashable SrcSpan 
Instance details

Defined in GHC.SrcLoc.Extra

Methods

hashWithSalt :: Int -> SrcSpan -> Int

hash :: SrcSpan -> Int

ToHie (LHsDoc GhcRn) 
Instance details

Defined in GHC.Iface.Ext.Ast

Methods

toHie :: LHsDoc GhcRn -> HieM [HieAST Type]

ToHie (Context (Located Name)) 
Instance details

Defined in GHC.Iface.Ext.Ast

Methods

toHie :: Context (Located Name) -> HieM [HieAST Type]

ToHie (Context (Located Var)) 
Instance details

Defined in GHC.Iface.Ext.Ast

Methods

toHie :: Context (Located Var) -> HieM [HieAST Type]

ToHie (Context (Located NoExtField)) 
Instance details

Defined in GHC.Iface.Ext.Ast

Methods

toHie :: Context (Located NoExtField) -> HieM [HieAST Type]

ToHie (IEContext (Located RecFieldInfo)) 
Instance details

Defined in GHC.Iface.Ext.Ast

Methods

toHie :: IEContext (Located RecFieldInfo) -> HieM [HieAST Type]

HiePass p => ToHie (Located (PatSynBind (GhcPass p) (GhcPass p))) 
Instance details

Defined in GHC.Iface.Ext.Ast

Methods

toHie :: Located (PatSynBind (GhcPass p) (GhcPass p)) -> HieM [HieAST Type]

ToHie (Located [LocatedAn NoEpAnns (HsDerivingClause GhcRn)]) 
Instance details

Defined in GHC.Iface.Ext.Ast

HasHaddock (Located (HsModule GhcPs)) 
Instance details

Defined in GHC.Parser.PostProcess.Haddock

HasHaddock (Located [LocatedAn NoEpAnns (HsDerivingClause GhcPs)]) 
Instance details

Defined in GHC.Parser.PostProcess.Haddock

NamedThing e => NamedThing (Located e) 
Instance details

Defined in GHC.Types.Name

Outputable e => Outputable (Located e) 
Instance details

Defined in GHC.Types.SrcLoc

Methods

ppr :: Located e -> SDoc Source #

(UnXRec p, Outputable (XRec p FieldLabelString)) => OutputableBndr (Located (FieldLabelStrings p)) 
Instance details

Defined in GHC.Hs.Expr

OutputableBndr (Located (AmbiguousFieldOcc (GhcPass p))) 
Instance details

Defined in GHC.Hs.Type

(UnXRec pass, OutputableBndr (XRec pass RdrName)) => OutputableBndr (GenLocated SrcSpan (FieldOcc pass)) 
Instance details

Defined in GHC.Hs.Type

type Rep SrcSpan Source # 
Instance details

Defined in GHC.SrcLoc.Extra

noSrcSpan :: SrcSpan Source #

Built-in "bad" SrcSpans for common sources of location uncertainty

hoistMaybe :: forall (m :: Type -> Type) b. Applicative m => Maybe b -> MaybeT m b Source #

Convert a Maybe computation to MaybeT.