Copyright | (C) 2012-2016 University of Twente |
---|---|
License | BSD2 (see the file LICENSE) |
Maintainer | Christiaan Baaij <christiaan.baaij@gmail.com> |
Safe Haskell | None |
Language | Haskell2010 |
Assortment of utility function used in the Clash library
Synopsis
- class Monad m => MonadUnique m where
- getUniqueM :: m Int
- data ClashException = ClashException SrcSpan String (Maybe String)
- assertPanic :: String -> Int -> a
- assertPprPanic :: HasCallStack => String -> Int -> Doc ann -> a
- pprPanic :: String -> Doc ann -> a
- callStackDoc :: HasCallStack => Doc ann
- warnPprTrace :: HasCallStack => Bool -> String -> Int -> Doc ann -> a -> a
- pprTrace :: String -> Doc ann -> a -> a
- pprTraceDebug :: String -> Doc ann -> a -> a
- pprDebugAndThen :: (String -> a) -> Doc ann -> Doc ann -> a
- curLoc :: Q Exp
- makeCached :: (MonadState s m, Hashable k, Eq k) => k -> Lens' s (HashMap k v) -> m v -> m v
- makeCachedU :: (MonadState s m, Uniquable k) => k -> Lens' s (UniqMap v) -> m v -> m v
- combineM :: Applicative f => (a -> f b) -> (c -> f d) -> (a, c) -> f (b, d)
- indexNote' :: HasCallStack => String -> Int -> [a] -> a
- indexNote :: HasCallStack => String -> [a] -> Int -> a
- clashLibVersion :: Version
- flogBase :: Integer -> Integer -> Maybe Int
- clogBase :: Integer -> Integer -> Maybe Int
- pkgIdFromTypeable :: Typeable a => a -> String
- reportTimeDiff :: UTCTime -> UTCTime -> String
- orElse :: Maybe a -> Maybe a -> Maybe a
- orElses :: [Maybe a] -> Maybe a
- wantedLanguageExtensions :: [Extension]
- unwantedLanguageExtensions :: [Extension]
- (<=<) :: Monad m => (b -> m c) -> (a -> m b) -> a -> m c
- (>=>) :: Monad m => (a -> m b) -> (b -> m c) -> a -> m c
- (&&&) :: Arrow a => a b c -> a b c' -> a b (c, c')
- second :: Arrow a => a b c -> a (d, b) (d, c)
- first :: Arrow a => a b c -> a (b, d) (c, d)
- (***) :: Arrow a => a b c -> a b' c' -> a (b, b') (c, c')
- on :: (b -> b -> c) -> (a -> b) -> a -> a -> c
- makeLenses :: Name -> DecsQ
- data SrcSpan
- noSrcSpan :: SrcSpan
- type HasCallStack = ?callStack :: CallStack
Documentation
class Monad m => MonadUnique m where Source #
A class that can generate unique numbers
getUniqueM :: m Int Source #
Get a new unique
Instances
MonadUnique (RewriteMonad extra) Source # | |
Defined in Clash.Rewrite.Types getUniqueM :: RewriteMonad extra Int Source # | |
Monad m => MonadUnique (StateT Int m) Source # | |
Defined in Clash.Util |
data ClashException Source #
Instances
Show ClashException Source # | |
Defined in Clash.Util showsPrec :: Int -> ClashException -> ShowS # show :: ClashException -> String # showList :: [ClashException] -> ShowS # | |
Exception ClashException Source # | |
Defined in Clash.Util |
assertPanic :: String -> Int -> a Source #
assertPprPanic :: HasCallStack => String -> Int -> Doc ann -> a Source #
callStackDoc :: HasCallStack => Doc ann Source #
:: HasCallStack | |
=> Bool | Trigger warning? |
-> String | File name |
-> Int | Line number |
-> Doc ann | Message |
-> a | Pass value (like trace) |
-> a |
pprTraceDebug :: String -> Doc ann -> a -> a 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.
:: (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
:: (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
combineM :: Applicative f => (a -> f b) -> (c -> f d) -> (a, c) -> f (b, d) Source #
:: 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
:: 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
pkgIdFromTypeable :: Typeable a => a -> String Source #
Get the package id of the type of a value >>> pkgIdFromTypeable (undefined :: TopEntity) "clash-prelude-0.99.3-64904d90747cb49e17166bbc86fec8678918e4ead3847193a395b258e680373c"
(>=>) :: Monad m => (a -> m b) -> (b -> m c) -> a -> m c infixr 1 #
Left-to-right composition of Kleisli arrows.
'(bs
' can be understood as the >=>
cs) ado
expression
do b <- bs a cs b
(&&&) :: Arrow a => a b c -> a b c' -> a b (c, c') infixr 3 #
Fanout: send the input to both argument arrows and combine their output.
The default definition may be overridden with a more efficient version if desired.
second :: Arrow a => a b c -> a (d, b) (d, c) #
A mirror image of first
.
The default definition may be overridden with a more efficient version if desired.
first :: Arrow a => a b c -> a (b, d) (c, d) #
Send the first component of the input through the argument arrow, and copy the rest unchanged to the output.
(***) :: Arrow a => a b c -> a b' c' -> a (b, b') (c, c') infixr 3 #
Split the input between the two argument arrows and combine their output. Note that this is in general not a functor.
The default definition may be overridden with a more efficient version if desired.
makeLenses :: Name -> DecsQ #
Build lenses (and traversals) with a sensible default configuration.
e.g.
data FooBar = Foo { _x, _y ::Int
} | Bar { _x ::Int
}makeLenses
''FooBar
will create
x ::Lens'
FooBarInt
x f (Foo a b) = (\a' -> Foo a' b) <$> f a x f (Bar a) = Bar <$> f a y ::Traversal'
FooBarInt
y f (Foo a b) = (\b' -> Foo a b') <$> f b y _ c@(Bar _) = pure c
makeLenses
=makeLensesWith
lensRules
Source Span
A SrcSpan
identifies either a specific portion of a text file
or a human-readable description of a location.
Instances
type HasCallStack = ?callStack :: CallStack #
Request a CallStack.
NOTE: The implicit parameter ?callStack :: CallStack
is an
implementation detail and should not be considered part of the
CallStack
API, we may decide to change the implementation in the
future.
Since: base-4.9.0.0