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

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

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

data ClashException Source #

Instances

Instances details
Exception ClashException Source # 
Instance details

Defined in Clash.Util

Show ClashException Source # 
Instance details

Defined in Clash.Util

reportTimeDiff :: UTCTime -> UTCTime -> String Source #

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

Methods

getUniqueM :: StateT Unique m Unique Source #

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

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

namePat :: Name -> Q Pat Source #

Construct a string pattern match out of the given TemplateHaskell name

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

callStackDoc :: HasCallStack => Doc ann Source #

warnPprTrace Source #

Arguments

:: HasCallStack 
=> Bool

Trigger warning?

-> String

File name

-> Int

Line number

-> Doc ann

Message

-> a

Pass value (like trace)

-> a 

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

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

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 #

Instances

Instances details
Binary SrcSpan 
Instance details

Defined in GHC.SrcLoc.Extra

Methods

put :: SrcSpan -> Put

get :: Get SrcSpan

putList :: [SrcSpan] -> Put

PrettyPrec SrcSpan Source # 
Instance details

Defined in Clash.Core.Pretty

NFData SrcSpan 
Instance details

Defined in GHC.Types.SrcLoc

Methods

rnf :: SrcSpan -> ()

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

Outputable SrcSpan 
Instance details

Defined in GHC.Types.SrcLoc

Methods

ppr :: SrcSpan -> SDoc

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

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

toConstr :: SrcSpan -> Constr

dataTypeOf :: SrcSpan -> DataType

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

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

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

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

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

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

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

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

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

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

Generic SrcSpan Source # 
Instance details

Defined in GHC.SrcLoc.Extra

Associated Types

type Rep SrcSpan 
Instance details

Defined in GHC.SrcLoc.Extra

type Rep SrcSpan = D1 ('MetaData "SrcSpan" "GHC.Types.SrcLoc" "ghc-9.10.3-inplace" 'False) (C1 ('MetaCons "RealSrcSpan" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 RealSrcSpan) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Maybe BufSpan))) :+: C1 ('MetaCons "UnhelpfulSpan" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 UnhelpfulSpanReason)))

Methods

from :: SrcSpan -> Rep SrcSpan x

to :: Rep SrcSpan x -> SrcSpan

Show SrcSpan 
Instance details

Defined in GHC.Types.SrcLoc

Eq SrcSpan 
Instance details

Defined in GHC.Types.SrcLoc

Methods

(==) :: SrcSpan -> SrcSpan -> Bool #

(/=) :: SrcSpan -> SrcSpan -> Bool #

Hashable SrcSpan Source # 
Instance details

Defined in GHC.SrcLoc.Extra

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

Methods

toHie :: Located [LocatedAn NoEpAnns (HsDerivingClause GhcRn)] -> HieM [HieAST Type]

HasHaddock (Located (HsModule GhcPs)) 
Instance details

Defined in GHC.Parser.PostProcess.Haddock

Methods

addHaddock :: Located (HsModule GhcPs) -> HdkA (Located (HsModule GhcPs))

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

Defined in GHC.Parser.PostProcess.Haddock

Methods

addHaddock :: Located [LocatedAn NoEpAnns (HsDerivingClause GhcPs)] -> HdkA (Located [LocatedAn NoEpAnns (HsDerivingClause GhcPs)])

NamedThing e => NamedThing (Located e) 
Instance details

Defined in GHC.Types.Name

Methods

getOccName :: Located e -> OccName

getName :: Located e -> Name

Outputable e => Outputable (Located e) 
Instance details

Defined in GHC.Types.SrcLoc

Methods

ppr :: Located e -> SDoc

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

Defined in GHC.Hs.Expr

Methods

pprBndr :: BindingSite -> Located (FieldLabelStrings p) -> SDoc

pprPrefixOcc :: Located (FieldLabelStrings p) -> SDoc

pprInfixOcc :: Located (FieldLabelStrings p) -> SDoc

bndrIsJoin_maybe :: Located (FieldLabelStrings p) -> JoinPointHood

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

Defined in GHC.Hs.Type

Methods

pprBndr :: BindingSite -> Located (AmbiguousFieldOcc (GhcPass p)) -> SDoc

pprPrefixOcc :: Located (AmbiguousFieldOcc (GhcPass p)) -> SDoc

pprInfixOcc :: Located (AmbiguousFieldOcc (GhcPass p)) -> SDoc

bndrIsJoin_maybe :: Located (AmbiguousFieldOcc (GhcPass p)) -> JoinPointHood

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

Defined in GHC.Hs.Type

Methods

pprBndr :: BindingSite -> GenLocated SrcSpan (FieldOcc pass) -> SDoc

pprPrefixOcc :: GenLocated SrcSpan (FieldOcc pass) -> SDoc

pprInfixOcc :: GenLocated SrcSpan (FieldOcc pass) -> SDoc

bndrIsJoin_maybe :: GenLocated SrcSpan (FieldOcc pass) -> JoinPointHood

type Rep SrcSpan 
Instance details

Defined in GHC.SrcLoc.Extra

type Rep SrcSpan = D1 ('MetaData "SrcSpan" "GHC.Types.SrcLoc" "ghc-9.10.3-inplace" 'False) (C1 ('MetaCons "RealSrcSpan" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 RealSrcSpan) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Maybe BufSpan))) :+: C1 ('MetaCons "UnhelpfulSpan" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 UnhelpfulSpanReason)))

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