| Copyright | (C) 2016 University of Twente 2017 Myrtle Software Ltd QBayLogic Google Inc. |
|---|---|
| License | BSD2 (see the file LICENSE) |
| Maintainer | Christiaan Baaij <christiaan.baaij@gmail.com> |
| Safe Haskell | Trustworthy |
| Language | Haskell2010 |
Clash.XException
Contents
Description
X: An exception for uninitialized values
>>>show (errorX "undefined" :: Integer, 4 :: Int)"(*** Exception: X: undefined CallStack (from HasCallStack): ...>>>showX (errorX "undefined" :: Integer, 4 :: Int)"(X,4)"
X: An exception for uninitialized values
data XException #
An exception representing an "uninitialised" value.
Instances
| Show XException # | |
Defined in Clash.XException Methods showsPrec :: Int -> XException -> ShowS # show :: XException -> String # showList :: [XException] -> ShowS # | |
| Exception XException # | |
Defined in Clash.XException Methods toException :: XException -> SomeException # fromException :: SomeException -> Maybe XException # displayException :: XException -> String # | |
errorX :: HasCallStack => String -> a #
Like error, but throwing an XException instead of an ErrorCall
The ShowX methods print these error-values as "X"; instead of error'ing
out with an exception.
isX :: NFData a => a -> Either String a #
Fully evaluate a value, returning if is throws Left msgXException.
isX 42 = Right 42 isX (XException msg) = Left msg isX _|_ = _|_
maybeX :: NFData a => a -> Maybe a #
Fully evaluate a value, returning Nothing if is throws XException.
maybeX 42 = Just 42 maybeX (XException msg) = Nothing maybeX _|_ = _|_
Printing X exceptions as "X"
Like the Show class, but values that normally throw an X exception are
converted to "X", instead of error'ing out with an exception.
>>>show (errorX "undefined" :: Integer, 4 :: Int)"(*** Exception: X: undefined CallStack (from HasCallStack): ...>>>showX (errorX "undefined" :: Integer, 4 :: Int)"(X,4)"
Can be derived using Generics:
{-# LANGUAGE DeriveGeneric, DeriveAnyClass #-}
import Clash.Prelude
import GHC.Generics
data T = MkTA Int | MkTB Bool
deriving (Show,Generic,ShowX)Methods
showsPrecX :: Int -> a -> ShowS #
Like showsPrec, but values that normally throw an X exception are
converted to "X", instead of error'ing out with an exception.
Like show, but values that normally throw an X exception are
converted to "X", instead of error'ing out with an exception.
Like showList, but values that normally throw an X exception are
converted to "X", instead of error'ing out with an exception.
showsPrecX :: (Generic a, GShowX (Rep a)) => Int -> a -> ShowS #
Like showsPrec, but values that normally throw an X exception are
converted to "X", instead of error'ing out with an exception.
Instances
| ShowX Bool # | |
| ShowX Char # | |
| ShowX Double # | |
| ShowX Float # | |
| ShowX Int # | |
| ShowX Int8 # | |
| ShowX Int16 # | |
| ShowX Int32 # | |
| ShowX Int64 # | |
| ShowX Integer # | |
| ShowX Word # | |
| ShowX Word8 # | |
| ShowX Word16 # | |
| ShowX Word32 # | |
| ShowX Word64 # | |
| ShowX () # | |
| ShowX String # | |
| ShowX Bit # | |
| ShowX a => ShowX [a] # | |
| ShowX a => ShowX (Maybe a) # | |
| ShowX a => ShowX (Ratio a) # | |
| ShowX a => ShowX (Complex a) # | |
| KnownNat n => ShowX (BitVector n) # | |
| ShowX (Index n) # | |
| KnownNat n => ShowX (BNat n) # | |
| KnownNat n => ShowX (UNat n) # | |
| ShowX (SNat n) # | |
| ShowX (Unsigned n) # | |
| ShowX (Signed n) # | |
| (ShowX a, ShowX b) => ShowX (Either a b) # | |
| (ShowX a, ShowX b) => ShowX (a, b) # | |
| ShowX a => ShowX (Vec n a) # | |
| ShowX a => ShowX (RTree n a) # | |
| (ShowX a, ShowX b, ShowX c) => ShowX (a, b, c) # | |
| (size ~ (int + frac), KnownNat frac, Integral (rep size)) => ShowX (Fixed rep int frac) # | |
| (ShowX a, ShowX b, ShowX c, ShowX d) => ShowX (a, b, c, d) # | |
| (ShowX a, ShowX b, ShowX c, ShowX d, ShowX e) => ShowX (a, b, c, d, e) # | |
| (ShowX a, ShowX b, ShowX c, ShowX d, ShowX e, ShowX f) => ShowX (a, b, c, d, e, f) # | |
| (ShowX a, ShowX b, ShowX c, ShowX d, ShowX e, ShowX f, ShowX g) => ShowX (a, b, c, d, e, f, g) # | |
| (ShowX a, ShowX b, ShowX c, ShowX d, ShowX e, ShowX f, ShowX g, ShowX h) => ShowX (a, b, c, d, e, f, g, h) # | |
| (ShowX a, ShowX b, ShowX c, ShowX d, ShowX e, ShowX f, ShowX g, ShowX h, ShowX i) => ShowX (a, b, c, d, e, f, g, h, i) # | |
| (ShowX a, ShowX b, ShowX c, ShowX d, ShowX e, ShowX f, ShowX g, ShowX h, ShowX i, ShowX j) => ShowX (a, b, c, d, e, f, g, h, i, j) # | |
| (ShowX a, ShowX b, ShowX c, ShowX d, ShowX e, ShowX f, ShowX g, ShowX h, ShowX i, ShowX j, ShowX k) => ShowX (a, b, c, d, e, f, g, h, i, j, k) # | |
| (ShowX a, ShowX b, ShowX c, ShowX d, ShowX e, ShowX f, ShowX g, ShowX h, ShowX i, ShowX j, ShowX k, ShowX l) => ShowX (a, b, c, d, e, f, g, h, i, j, k, l) # | |
| (ShowX a, ShowX b, ShowX c, ShowX d, ShowX e, ShowX f, ShowX g, ShowX h, ShowX i, ShowX j, ShowX k, ShowX l, ShowX m) => ShowX (a, b, c, d, e, f, g, h, i, j, k, l, m) # | |
| (ShowX a, ShowX b, ShowX c, ShowX d, ShowX e, ShowX f, ShowX g, ShowX h, ShowX i, ShowX j, ShowX k, ShowX l, ShowX m, ShowX n) => ShowX (a, b, c, d, e, f, g, h, i, j, k, l, m, n) # | |
| (ShowX a, ShowX b, ShowX c, ShowX d, ShowX e, ShowX f, ShowX g, ShowX h, ShowX i, ShowX j, ShowX k, ShowX l, ShowX m, ShowX n, ShowX o) => ShowX (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) # | |
showsX :: ShowX a => a -> ShowS #
Like shows, but values that normally throw an X exception are
converted to "X", instead of error'ing out with an exception.
printX :: ShowX a => a -> IO () #
Like print, but values that normally throw an X exception are
converted to "X", instead of error'ing out with an exception
showsPrecXWith :: (Int -> a -> ShowS) -> Int -> a -> ShowS #
Use when you want to create a ShowX instance where:
- There is no
Genericinstance for your data type - The
Genericderived ShowX method would traverse into the (hidden) implementation details of your data type, and you just want to show the entire value as "X".
Can be used like:
data T = ... instance Show T where ... instance ShowX T where showsPrecX = showsPrecXWith showsPrec
Strict evaluation
Orphan instances
| Generic (a, b, c, d, e, f, g, h) # | |
| Generic (a, b, c, d, e, f, g, h, i) # | |
| Generic (a, b, c, d, e, f, g, h, i, j) # | |
| Generic (a, b, c, d, e, f, g, h, i, j, k) # | |
| Generic (a, b, c, d, e, f, g, h, i, j, k, l) # | |
| Generic (a, b, c, d, e, f, g, h, i, j, k, l, m) # | |
| Generic (a, b, c, d, e, f, g, h, i, j, k, l, m, n) # | |
| Generic (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) # | |