clash-prelude-1.8.4: Clash: a functional hardware description language - Prelude library

Copyright | (C) 2016 University of Twente 2017 Google Inc. 2017-2019 Myrtle Software Ltd 2017-2025 QBayLogic B.V.
License | BSD2 (see the file LICENSE)
Maintainer | QBayLogic B.V. <devops@qbaylogic.com>
Safe Haskell | Trustworthy
Language | Haskell2010

Clash.XException.Internal

Contents

- Printing `XException`s as `undefined`
- Internals

Description

`XException`: An exception for uninitialized values

    >>> show (errorX "No value here" :: Integer, 4 :: Int)
    "(*** Exception: X: No value here
    CallStack (from HasCallStack):
    ...
    >>> showX (errorX "No value here" :: Integer, 4 :: Int)
    "(undefined,4)"

Synopsis

- newtype XException = XException String
- showsX :: ShowX a => a -> ShowS
- showsPrecXWith :: (Int -> a -> ShowS) -> Int -> a -> ShowS
- showXWith :: (a -> ShowS) -> a -> ShowS
- class GShowX (f :: Type -> Type) where
  - gshowsPrecX :: ShowType -> Int -> f a -> ShowS
  - isNullary :: f a -> Bool
- class GDeepErrorX (f :: Type -> Type) where
  - gDeepErrorX :: HasCallStack => String -> f a
- class GHasUndefined (f :: Type -> Type) where
  - gHasUndefined :: f a -> Bool
- class GEnsureSpine (f :: Type -> Type) where
  - gEnsureSpine :: f a -> f a
- class GNFDataX arity (f :: Type -> Type) where
  - grnfX :: RnfArgs arity a -> f a -> ()
- data Zero
- data One
- data ShowType
  - = Rec
  - | Tup
  - | Pref
  - | Inf String
- data RnfArgs arity a where
  - RnfArgs0 :: forall a. RnfArgs Zero a
  - RnfArgs1 :: forall a. (a -> ()) -> RnfArgs One a
- class NFDataX1 (f :: Type -> Type) where
  - liftRnfX :: (a -> ()) -> f a -> ()
- showListX__ :: (a -> ShowS) -> [a] -> ShowS
- genericShowsPrecX :: (Generic a, GShowX (Rep a)) => Int -> a -> ShowS

# Documentation

newtype XException Source #

An exception representing an "uninitialized" value.

Constructors

XException String |

#### Instances

Instances details

Exception XException Source # |
Instance details Defined in Clash.XException.Internal Methods toException :: XException -> SomeException Source # fromException :: SomeException -> Maybe XException Source # displayException :: XException -> String Source # backtraceDesired :: XException -> Bool Source #
Show XException Source # |
Instance details Defined in Clash.XException.Internal Methods showsPrec :: Int -> XException -> ShowS Source # show :: XException -> String Source # showList :: [XException] -> ShowS Source #

# Printing `XException`s as `undefined`

showsX :: ShowX a => a -> ShowS Source #

Like `shows`, but values that normally throw an `XException` are converted to `undefined`, instead of error'ing out with an exception.

showsPrecXWith :: (Int -> a -> ShowS) -> Int -> a -> ShowS Source #

Use when you want to create a `ShowX` instance where:

- There is no `Generic` instance for your data type
- The `Generic` derived ShowX method would traverse into the (hidden) implementation details of your data type, and you just want to show the entire value as `undefined`.

Can be used like:

    data T = ...

    instance Show T where ...

    instance ShowX T where
      showsPrecX = showsPrecXWith showsPrec

showXWith :: (a -> ShowS) -> a -> ShowS Source #

# Internals

class GShowX (f :: Type -> Type) where Source #

Minimal complete definition

gshowsPrecX

Methods

gshowsPrecX :: ShowType -> Int -> f a -> ShowS Source #

isNullary :: f a -> Bool Source #

#### Instances

Instances details

GShowX (U1 :: Type -> Type) Source # |
Instance details Defined in Clash.XException.Internal Methods gshowsPrecX :: ShowType -> Int -> U1 a -> ShowS Source # isNullary :: U1 a -> Bool Source #
GShowX (UChar :: Type -> Type) Source # |
Instance details Defined in Clash.XException.Internal Methods gshowsPrecX :: ShowType -> Int -> UChar a -> ShowS Source # isNullary :: UChar a -> Bool Source #
GShowX (UDouble :: Type -> Type) Source # |
Instance details Defined in Clash.XException.Internal Methods gshowsPrecX :: ShowType -> Int -> UDouble a -> ShowS Source # isNullary :: UDouble a -> Bool Source #
GShowX (UFloat :: Type -> Type) Source # |
Instance details Defined in Clash.XException.Internal Methods gshowsPrecX :: ShowType -> Int -> UFloat a -> ShowS Source # isNullary :: UFloat a -> Bool Source #
GShowX (UInt :: Type -> Type) Source # |
Instance details Defined in Clash.XException.Internal Methods gshowsPrecX :: ShowType -> Int -> UInt a -> ShowS Source # isNullary :: UInt a -> Bool Source #
GShowX (UWord :: Type -> Type) Source # |
Instance details Defined in Clash.XException.Internal Methods gshowsPrecX :: ShowType -> Int -> UWord a -> ShowS Source # isNullary :: UWord a -> Bool Source #
(GShowX a, GShowX b) => GShowX (a :*: b) Source # |
Instance details Defined in Clash.XException.Internal Methods gshowsPrecX :: ShowType -> Int -> (a :*: b) a0 -> ShowS Source # isNullary :: (a :*: b) a0 -> Bool Source #
(GShowX a, GShowX b) => GShowX (a :+: b) Source # |
Instance details Defined in Clash.XException.Internal Methods gshowsPrecX :: ShowType -> Int -> (a :+: b) a0 -> ShowS Source # isNullary :: (a :+: b) a0 -> Bool Source #
ShowX c => GShowX (K1 i c :: Type -> Type) Source # |
Instance details Defined in Clash.XException.Internal Methods gshowsPrecX :: ShowType -> Int -> K1 i c a -> ShowS Source # isNullary :: K1 i c a -> Bool Source #
(GShowX a, Constructor c) => GShowX (M1 C c a) Source # |
Instance details Defined in Clash.XException.Internal Methods gshowsPrecX :: ShowType -> Int -> M1 C c a a0 -> ShowS Source # isNullary :: M1 C c a a0 -> Bool Source #
GShowX a => GShowX (M1 D d a) Source # |
Instance details Defined in Clash.XException.Internal Methods gshowsPrecX :: ShowType -> Int -> M1 D d a a0 -> ShowS Source # isNullary :: M1 D d a a0 -> Bool Source #
(Selector s, GShowX a) => GShowX (M1 S s a) Source # |
Instance details Defined in Clash.XException.Internal Methods gshowsPrecX :: ShowType -> Int -> M1 S s a a0 -> ShowS Source # isNullary :: M1 S s a a0 -> Bool Source #

class GDeepErrorX (f :: Type -> Type) where Source #

Methods

gDeepErrorX :: HasCallStack => String -> f a Source #

#### Instances

Instances details

GDeepErrorX (U1 :: Type -> Type) Source # |
Instance details Defined in Clash.XException.Internal Methods gDeepErrorX :: HasCallStack => String -> U1 a Source #
GDeepErrorX (V1 :: Type -> Type) Source # |
Instance details Defined in Clash.XException.Internal Methods gDeepErrorX :: HasCallStack => String -> V1 a Source #
(GDeepErrorX f, GDeepErrorX g) => GDeepErrorX (f :*: g) Source # |
Instance details Defined in Clash.XException.Internal Methods gDeepErrorX :: HasCallStack => String -> (f :*: g) a Source #
GDeepErrorX (f :+: g) Source # |
Instance details Defined in Clash.XException.Internal Methods gDeepErrorX :: HasCallStack => String -> (f :+: g) a Source #
NFDataX c => GDeepErrorX (K1 i c :: Type -> Type) Source # |
Instance details Defined in Clash.XException.Internal Methods gDeepErrorX :: HasCallStack => String -> K1 i c a Source #
GDeepErrorX a => GDeepErrorX (M1 m d a) Source # |
Instance details Defined in Clash.XException.Internal Methods gDeepErrorX :: HasCallStack => String -> M1 m d a a0 Source #

class GHasUndefined (f :: Type -> Type) where Source #

Methods

gHasUndefined :: f a -> Bool Source #

#### Instances

Instances details

GHasUndefined (U1 :: Type -> Type) Source # |
Instance details Defined in Clash.XException.Internal Methods gHasUndefined :: U1 a -> Bool Source #
GHasUndefined (V1 :: Type -> Type) Source # |
Instance details Defined in Clash.XException.Internal Methods gHasUndefined :: V1 a -> Bool Source #
(GHasUndefined a, GHasUndefined b) => GHasUndefined (a :*: b) Source # |
Instance details Defined in Clash.XException.Internal Methods gHasUndefined :: (a :*: b) a0 -> Bool Source #
(GHasUndefined a, GHasUndefined b) => GHasUndefined (a :+: b) Source # |
Instance details Defined in Clash.XException.Internal Methods gHasUndefined :: (a :+: b) a0 -> Bool Source #
NFDataX a => GHasUndefined (K1 i a :: Type -> Type) Source # |
Instance details Defined in Clash.XException.Internal Methods gHasUndefined :: K1 i a a0 -> Bool Source #
GHasUndefined a => GHasUndefined (M1 i c a) Source # |
Instance details Defined in Clash.XException.Internal Methods gHasUndefined :: M1 i c a a0 -> Bool Source #

class GEnsureSpine (f :: Type -> Type) where Source #

Methods

gEnsureSpine :: f a -> f a Source #

#### Instances

Instances details

GEnsureSpine (U1 :: Type -> Type) Source # |
Instance details Defined in Clash.XException.Internal Methods gEnsureSpine :: U1 a -> U1 a Source #
GEnsureSpine (V1 :: Type -> Type) Source # |
Instance details Defined in Clash.XException.Internal Methods gEnsureSpine :: V1 a -> V1 a Source #
(GEnsureSpine a, GEnsureSpine b) => GEnsureSpine (a :*: b) Source # |
Instance details Defined in Clash.XException.Internal Methods gEnsureSpine :: (a :*: b) a0 -> (a :*: b) a0 Source #
(GEnsureSpine a, GEnsureSpine b) => GEnsureSpine (a :+: b) Source # |
Instance details Defined in Clash.XException.Internal Methods gEnsureSpine :: (a :+: b) a0 -> (a :+: b) a0 Source #
NFDataX a => GEnsureSpine (K1 i a :: Type -> Type) Source # |
Instance details Defined in Clash.XException.Internal Methods gEnsureSpine :: K1 i a a0 -> K1 i a a0 Source #
GEnsureSpine a => GEnsureSpine (M1 i c a) Source # |
Instance details Defined in Clash.XException.Internal Methods gEnsureSpine :: M1 i c a a0 -> M1 i c a a0 Source #

class GNFDataX arity (f :: Type -> Type) where Source #

Hidden internal type-class. Adds a generic implementation for the "NFData" part of `NFDataX`

Methods

grnfX :: RnfArgs arity a -> f a -> () Source #

#### Instances

Instances details

GNFDataX One Par1 Source # |
Instance details Defined in Clash.XException.Internal Methods grnfX :: RnfArgs One a -> Par1 a -> () Source #
GNFDataX arity (U1 :: Type -> Type) Source # |
Instance details Defined in Clash.XException.Internal Methods grnfX :: RnfArgs arity a -> U1 a -> () Source #
GNFDataX arity (V1 :: Type -> Type) Source # |
Instance details Defined in Clash.XException.Internal Methods grnfX :: RnfArgs arity a -> V1 a -> () Source #
NFDataX1 f => GNFDataX One (Rec1 f) Source # |
Instance details Defined in Clash.XException.Internal Methods grnfX :: RnfArgs One a -> Rec1 f a -> () Source #
(GNFDataX arity a, GNFDataX arity b) => GNFDataX arity (a :*: b) Source # |
Instance details Defined in Clash.XException.Internal Methods grnfX :: RnfArgs arity a0 -> (a :*: b) a0 -> () Source #
(GNFDataX arity a, GNFDataX arity b) => GNFDataX arity (a :+: b) Source # |
Instance details Defined in Clash.XException.Internal Methods grnfX :: RnfArgs arity a0 -> (a :+: b) a0 -> () Source #
NFDataX a => GNFDataX arity (K1 i a :: Type -> Type) Source # |
Instance details Defined in Clash.XException.Internal Methods grnfX :: RnfArgs arity a0 -> K1 i a a0 -> () Source #
(NFDataX1 f, GNFDataX One g) => GNFDataX One (f :.: g) Source # |
Instance details Defined in Clash.XException.Internal Methods grnfX :: RnfArgs One a -> (f :.: g) a -> () Source #
GNFDataX arity a => GNFDataX arity (M1 i c a) Source # |
Instance details Defined in Clash.XException.Internal Methods grnfX :: RnfArgs arity a0 -> M1 i c a a0 -> () Source #

data Zero Source #

data One Source #

#### Instances

Instances details

GNFDataX One Par1 Source # |
Instance details Defined in Clash.XException.Internal Methods grnfX :: RnfArgs One a -> Par1 a -> () Source #
NFDataX1 f => GNFDataX One (Rec1 f) Source # |
Instance details Defined in Clash.XException.Internal Methods grnfX :: RnfArgs One a -> Rec1 f a -> () Source #
(NFDataX1 f, GNFDataX One g) => GNFDataX One (f :.: g) Source # |
Instance details Defined in Clash.XException.Internal Methods grnfX :: RnfArgs One a -> (f :.: g) a -> () Source #

data ShowType Source #

Constructors

Rec |
Tup |
Pref |
Inf String |

data RnfArgs arity a where Source #

Constructors

RnfArgs0 :: forall a. RnfArgs Zero a |
RnfArgs1 :: forall a. (a -> ()) -> RnfArgs One a |

class NFDataX1 (f :: Type -> Type) where Source #

A class of functors that can be fully evaluated, according to semantics of NFDataX.

Minimal complete definition

Nothing

Methods

liftRnfX :: (a -> ()) -> f a -> () Source #

`liftRnfX` should reduce its argument to normal form (that is, fully evaluate all sub-components), given an argument to reduce `a` arguments, and then return `()`.

See `rnfX` for the generic deriving.

default liftRnfX :: (Generic1 f, GNFDataX One (Rep1 f)) => (a -> ()) -> f a -> () Source #

showListX__ :: (a -> ShowS) -> [a] -> ShowS Source #

genericShowsPrecX :: (Generic a, GShowX (Rep a)) => Int -> a -> ShowS Source #