diff --git a/clash-prelude.cabal b/clash-prelude.cabal index 662a928937..0266c6b306 100644 --- a/clash-prelude.cabal +++ b/clash-prelude.cabal @@ -195,6 +195,7 @@ Library base >= 4.8.0.0 && < 5, bifunctors >= 5.4.0 && < 6.0, constraints >= 0.8 && < 1.0, + containers >= 0.4.0 && < 0.6, data-binary-ieee754 >= 0.4.4 && < 0.6, data-default >= 0.5.3 && < 0.8, integer-gmp >= 0.5.1.0 && < 1.1, diff --git a/src/Clash/Examples.hs b/src/Clash/Examples.hs index 40741169b3..f405180ee1 100644 --- a/src/Clash/Examples.hs +++ b/src/Clash/Examples.hs @@ -6,7 +6,7 @@ Licence : Creative Commons 4.0 (CC BY 4.0) (http://creativecommons.org/license {-# LANGUAGE NoImplicitPrelude, CPP, TemplateHaskell, DataKinds, BinaryLiterals, FlexibleContexts, GADTs, TypeOperators, TypeApplications, - RecordWildCards #-} + RecordWildCards, DeriveAnyClass #-} {-# OPTIONS_GHC -fno-warn-unused-imports #-} {-# OPTIONS_GHC -fno-warn-unused-binds #-} {-# OPTIONS_GHC -fno-warn-type-defaults #-} @@ -172,6 +172,7 @@ data RxReg , _rx_d2 :: Bit , _rx_busy :: Bool } + deriving Undefined makeLenses ''RxReg @@ -183,6 +184,7 @@ data TxReg , _tx_out :: Bit , _tx_cnt :: Unsigned 4 } + deriving Undefined makeLenses ''TxReg diff --git a/src/Clash/Explicit/BlockRam.hs b/src/Clash/Explicit/BlockRam.hs index 2aac0eb953..b666e7f142 100644 --- a/src/Clash/Explicit/BlockRam.hs +++ b/src/Clash/Explicit/BlockRam.hs @@ -18,7 +18,7 @@ We start with the definition of the Instructions, Register names and machine codes: @ -{\-\# LANGUAGE RecordWildCards, TupleSections \#-\} +{\-\# LANGUAGE RecordWildCards, TupleSections, DeriveAnyClass \#-\} module CPU where import Clash.Explicit.Prelude @@ -403,12 +403,12 @@ import Clash.Signal.Internal import Clash.Signal.Bundle (unbundle) import Clash.Sized.Unsigned (Unsigned) import Clash.Sized.Vector (Vec, toList) -import Clash.XException (errorX, maybeX, seqX) +import Clash.XException (Undefined, errorX, maybeX, seqX) {- $setup >>> import Clash.Explicit.Prelude as C >>> import qualified Data.List as L ->>> :set -XDataKinds -XRecordWildCards -XTupleSections +>>> :set -XDataKinds -XRecordWildCards -XTupleSections -XDeriveAnyClass >>> type InstrAddr = Unsigned 8 >>> type MemAddr = Unsigned 5 >>> type Value = Signed 8 @@ -421,7 +421,7 @@ data Reg | RegC | RegD | RegE - deriving (Eq,Show,Enum) + deriving (Eq,Show,Enum,Undefined) :} >>> :{ @@ -786,7 +786,7 @@ blockRam# clk content rd wen = case clockEnable clk of -- | Create read-after-write blockRAM from a read-before-write one readNew - :: Eq addr + :: (Eq addr, Undefined a) => Reset domain synchronous -> Clock domain gated -> (Signal domain addr -> Signal domain (Maybe (addr, a)) -> Signal domain a) diff --git a/src/Clash/Explicit/DDR.hs b/src/Clash/Explicit/DDR.hs index 2a7fa712bc..a22d92573b 100644 --- a/src/Clash/Explicit/DDR.hs +++ b/src/Clash/Explicit/DDR.hs @@ -128,6 +128,7 @@ ddrIn# (GatedClock _ _ ena) (Async rst) i0 i1 i2 = -- -- Produces a DDR output signal from a normal signal of pairs of input. ddrOut :: ( HasCallStack + , Undefined a , fast ~ 'Dom n pFast , slow ~ 'Dom n (2*pFast)) => Clock slow gated -- ^ clock @@ -139,6 +140,7 @@ ddrOut clk rst i0 = uncurry (withFrozenCallStack $ ddrOut# clk rst i0) . unbundl ddrOut# :: ( HasCallStack + , Undefined a , fast ~ 'Dom n pFast , slow ~ 'Dom n (2*pFast)) => Clock slow gated diff --git a/src/Clash/Explicit/Mealy.hs b/src/Clash/Explicit/Mealy.hs index 2fe1006604..09866207ee 100644 --- a/src/Clash/Explicit/Mealy.hs +++ b/src/Clash/Explicit/Mealy.hs @@ -21,6 +21,7 @@ module Clash.Explicit.Mealy where import Clash.Explicit.Signal (Bundle (..), Clock, Reset, Signal, register) +import Clash.XException (Undefined) {- $setup >>> :set -XDataKinds -XTypeApplications @@ -75,7 +76,8 @@ let macT s (x,y) = (s',s) -- s1 = 'mealy' clk rst mac 0 ('bundle' (a,x)) -- s2 = 'mealy' clk rst mac 0 ('bundle' (b,y)) -- @ -mealy :: Clock dom gated -- ^ 'Clock' to synchronize to +mealy :: Undefined s + => Clock dom gated -- ^ 'Clock' to synchronize to -> Reset dom synchronous -> (s -> i -> (s,o)) -- ^ Transfer function in mealy machine form: -- @state -> input -> (newstate,output)@ @@ -115,7 +117,7 @@ mealy clk rst f iS = -- (i1,b1) = 'mealyB' clk rst f 0 (a,b) -- (i2,b2) = 'mealyB' clk rst f 3 (i1,c) -- @ -mealyB :: (Bundle i, Bundle o) +mealyB :: (Bundle i, Bundle o, Undefined s) => Clock dom gated -> Reset dom synchronous -> (s -> i -> (s,o)) -- ^ Transfer function in mealy machine form: diff --git a/src/Clash/Explicit/Moore.hs b/src/Clash/Explicit/Moore.hs index 51103116dd..b0a4bded99 100644 --- a/src/Clash/Explicit/Moore.hs +++ b/src/Clash/Explicit/Moore.hs @@ -23,6 +23,7 @@ module Clash.Explicit.Moore where import Clash.Explicit.Signal (Bundle (..), Clock, Reset, Signal, register) +import Clash.XException (Undefined) {- $setup >>> :set -XDataKinds -XTypeApplications @@ -69,7 +70,8 @@ import Clash.Explicit.Signal (Bundle (..), Clock, Reset, Signal, register) -- s2 = 'moore' clk rst mac id 0 ('bundle' (b,y)) -- @ moore - :: Clock domain gated -- ^ 'Clock' to synchronize to + :: Undefined s + => Clock domain gated -- ^ 'Clock' to synchronize to -> Reset domain synchronous -> (s -> i -> s) -- ^ Transfer function in moore machine form: -- @state -> input -> newstate@ @@ -88,7 +90,8 @@ moore clk rst ft fo iS = -- | Create a synchronous function from a combinational function describing -- a moore machine without any output logic medvedev - :: Clock domain gated + :: Undefined s + => Clock domain gated -> Reset domain synchronous -> (s -> i -> s) -> s @@ -124,7 +127,7 @@ medvedev clk rst tr st = moore clk rst tr id st -- (i2,b2) = 'mooreB' clk rst t o 3 (i1,c) -- @ mooreB - :: (Bundle i, Bundle o) + :: (Bundle i, Bundle o, Undefined s) => Clock domain gated -> Reset domain synchronous -> (s -> i -> s) -- ^ Transfer function in moore machine form: @@ -140,7 +143,7 @@ mooreB clk rst ft fo iS i = unbundle (moore clk rst ft fo iS (bundle i)) -- | A version of 'medvedev' that does automatic 'Bundle'ing medvedevB - :: (Bundle i, Bundle s) + :: (Bundle i, Bundle s, Undefined s) => Clock domain gated -> Reset domain synchronous -> (s -> i -> s) diff --git a/src/Clash/Explicit/Prelude.hs b/src/Clash/Explicit/Prelude.hs index b01070d427..f6fb968c75 100644 --- a/src/Clash/Explicit/Prelude.hs +++ b/src/Clash/Explicit/Prelude.hs @@ -178,7 +178,7 @@ import Clash.XException -- [<1,0,0,0>,<2,1,0,0>,<3,2,1,0>,<4,3,2,1>,<5,4,3,2>... -- ... window - :: (KnownNat n, Default a) + :: (KnownNat n, Default a, Undefined a) => Clock domain gated -- ^ Clock to which the incoming signal is synchronized -> Reset domain synchronous @@ -205,7 +205,7 @@ window clk rst x = res -- [<0,0,0>,<1,0,0>,<2,1,0>,<3,2,1>,<4,3,2>... -- ... windowD - :: (KnownNat n, Default a) + :: (KnownNat n, Default a, Undefined a) => Clock domain gated -- ^ Clock to which the incoming signal is synchronized -> Reset domain synchronous diff --git a/src/Clash/Explicit/Prelude/Safe.hs b/src/Clash/Explicit/Prelude/Safe.hs index 25afc3f0d9..c0d7ce504c 100644 --- a/src/Clash/Explicit/Prelude/Safe.hs +++ b/src/Clash/Explicit/Prelude/Safe.hs @@ -161,7 +161,7 @@ import Clash.XException -- [(8,8),(1,1),(2,2),(3,3)... -- ... registerB - :: Bundle a + :: (Bundle a, Undefined a) => Clock domain gated -> Reset domain synchronous -> a @@ -172,7 +172,7 @@ registerB clk rst i = unbundle Prelude.. register clk rst i Prelude.. bundle -- | Give a pulse when the 'Signal' goes from 'minBound' to 'maxBound' isRising - :: (Bounded a, Eq a) + :: (Bounded a, Eq a, Undefined a) => Clock domain gated -> Reset domain synchronous -> a -- ^ Starting value @@ -186,7 +186,7 @@ isRising clk rst is s = liftA2 edgeDetect prev s -- | Give a pulse when the 'Signal' goes from 'maxBound' to 'minBound' isFalling - :: (Bounded a, Eq a) + :: (Bounded a, Eq a, Undefined a) => Clock domain gated -> Reset domain synchronous -> a -- ^ Starting value diff --git a/src/Clash/Explicit/ROM.hs b/src/Clash/Explicit/ROM.hs index d34fd0b191..5cb793680f 100644 --- a/src/Clash/Explicit/ROM.hs +++ b/src/Clash/Explicit/ROM.hs @@ -8,10 +8,11 @@ ROMs -} {-# LANGUAGE DataKinds #-} +{-# LANGUAGE GADTs #-} {-# LANGUAGE MagicHash #-} {-# LANGUAGE TypeOperators #-} -{-# LANGUAGE Safe #-} +{-# LANGUAGE Trustworthy #-} {-# OPTIONS_GHC -fplugin GHC.TypeLits.KnownNat.Solver #-} {-# OPTIONS_HADDOCK show-extensions #-} @@ -26,18 +27,14 @@ module Clash.Explicit.ROM where import Data.Array ((!),listArray) +import GHC.Stack (withFrozenCallStack) import GHC.TypeLits (KnownNat, type (^)) import Prelude hiding (length) --- import Clash.Signal (Signal) --- import Clash.Signal.Explicit (Signal', SClock, systemClockGen) -import Clash.Explicit.Signal (Clock, Signal, delay) - +import Clash.Signal.Internal (Clock (..), Signal (..)) import Clash.Sized.Unsigned (Unsigned) --- import Clash.Signal.Explicit (register') import Clash.Sized.Vector (Vec, length, toList) --- import Clash.XException (errorX) - +import Clash.XException (errorX, seqX) -- | A ROM with a synchronous read port, with space for 2^@n@ elements -- @@ -90,8 +87,21 @@ rom# -> Signal domain Int -- ^ Read address @rd@ -> Signal domain a -- ^ The value of the ROM at address @rd@ from the previous clock cycle -rom# clk content rd = delay clk ((arr !) <$> rd) +rom# clk content rd = go clk ((arr !) <$> rd) where szI = length content arr = listArray (0,szI-1) (toList content) + + go :: Clock domain gated + -> Signal domain a + -> Signal domain a + go Clock {} = + \s -> withFrozenCallStack (errorX "rom: initial value undefined") :- s + + go (GatedClock _ _ en) = + go' (withFrozenCallStack (errorX "rom: initial value undefined")) en + + go' o (e :- es) as@(~(x :- xs)) = + -- See [Note: register strictness annotations] + o `seqX` o :- (as `seq` if e then go' x es xs else go' o es xs) {-# NOINLINE rom# #-} diff --git a/src/Clash/Explicit/Signal.hs b/src/Clash/Explicit/Signal.hs index 60dbce9698..2ad748eda0 100644 --- a/src/Clash/Explicit/Signal.hs +++ b/src/Clash/Explicit/Signal.hs @@ -201,6 +201,8 @@ import GHC.Stack (HasCallStack, withFrozenCallStack) import Clash.Signal.Internal import Clash.Signal.Bundle (Bundle (..)) +import Clash.XException (Undefined) + {- $setup >>> :set -XDataKinds -XTypeApplications >>> import Clash.Explicit.Prelude @@ -457,7 +459,7 @@ repSchedule high low = take low $ repSchedule' low high 1 -- >>> printX (sampleN 3 (delay systemClockGen (fromList [1,2,3,4]))) -- [X,1,2] delay - :: HasCallStack + :: (HasCallStack, Undefined a) => Clock domain gated -- ^ Clock -> Signal domain a @@ -471,7 +473,7 @@ delay = \clk i -> withFrozenCallStack (delay# clk i) -- >>> sampleN 3 (register systemClockGen systemResetGen 8 (fromList [1,2,3,4])) -- [8,1,2] register - :: HasCallStack + :: (HasCallStack, Undefined a) => Clock domain gated -- ^ clock -> Reset domain synchronous @@ -507,7 +509,7 @@ register = \clk rst initial i -> withFrozenCallStack -- >>> sampleN 8 (count systemClockGen systemResetGen) -- [0,0,1,1,2,2,3,3] regMaybe - :: HasCallStack + :: (HasCallStack, Undefined a) => Clock domain gated -- ^ Clock -> Reset domain synchronous @@ -536,7 +538,8 @@ regMaybe = \clk rst initial iM -> withFrozenCallStack -- >>> sampleN 8 (count systemClockGen systemResetGen) -- [0,0,1,1,2,2,3,3] regEn - :: Clock domain clk + :: Undefined a + => Clock domain clk -- ^ Clock -> Reset domain synchronous -- ^ Reset (active-high), 'regEn' outputs the reset value when the diff --git a/src/Clash/Explicit/Signal/Delayed.hs b/src/Clash/Explicit/Signal/Delayed.hs index 54a6d23783..617a3296a8 100644 --- a/src/Clash/Explicit/Signal/Delayed.hs +++ b/src/Clash/Explicit/Signal/Delayed.hs @@ -56,6 +56,7 @@ import Clash.Sized.Vector import Clash.Explicit.Signal (Clock, Domain, Reset, Signal, register, fromList, fromList_lazy, bundle, unbundle) +import Clash.XException (Undefined) {- $setup >>> :set -XDataKinds @@ -124,7 +125,7 @@ dfromList_lazy = coerce . fromList_lazy -- [0,0,0,1,2,3] delayed :: forall domain gated synchronous a n d - . KnownNat d + . (KnownNat d, Undefined a) => Clock domain gated -> Reset domain synchronous -> Vec d a @@ -151,7 +152,7 @@ delayed clk rst m ds = coerce (delaySignal (coerce ds)) -- >>> sampleN 6 (delay2 systemClockGen systemResetGen (dfromList [1..])) -- [0,0,1,2,3,4] delayedI - :: (Default a, KnownNat d) + :: (Default a, KnownNat d, Undefined a) => Clock domain gated -> Reset domain synchronous -> DSignal domain n a diff --git a/src/Clash/Explicit/Synchronizer.hs b/src/Clash/Explicit/Synchronizer.hs index de61fadc94..dba58e9d1b 100644 --- a/src/Clash/Explicit/Synchronizer.hs +++ b/src/Clash/Explicit/Synchronizer.hs @@ -60,6 +60,7 @@ import Clash.Promoted.Nat (SNat (..), pow2SNat) import Clash.Promoted.Nat.Literals (d0) import Clash.Signal (mux) import Clash.Sized.BitVector (BitVector, (++#)) +import Clash.XException (Undefined) -- * Dual flip-flop synchronizer @@ -86,7 +87,8 @@ import Clash.Sized.BitVector (BitVector, (++#)) -- If you want to have /safe/ __word__-synchronisation use -- 'asyncFIFOSynchronizer'. dualFlipFlopSynchronizer - :: Clock domain1 gated1 + :: Undefined a + => Clock domain1 gated1 -- ^ 'Clock' to which the incoming data is synchronised -> Clock domain2 gated2 -- ^ 'Clock' to which the outgoing data is synchronised diff --git a/src/Clash/Prelude.hs b/src/Clash/Prelude.hs index 16fb297f09..d592afc503 100644 --- a/src/Clash/Prelude.hs +++ b/src/Clash/Prelude.hs @@ -197,7 +197,7 @@ It instead exports the identically named functions defined in terms of -- [<1,0,0,0>,<2,1,0,0>,<3,2,1,0>,<4,3,2,1>,<5,4,3,2>... -- ... window - :: (KnownNat n, Default a, HiddenClockReset domain gated synchronous) + :: (KnownNat n, Default a, Undefined a, HiddenClockReset domain gated synchronous) => Signal domain a -- ^ Signal to create a window over -> Vec (n + 1) (Signal domain a) -- ^ Window of at least size 1 window = hideClockReset E.window @@ -213,7 +213,7 @@ window = hideClockReset E.window -- [<0,0,0>,<1,0,0>,<2,1,0>,<3,2,1>,<4,3,2>... -- ... windowD - :: (KnownNat n, Default a, HiddenClockReset domain gated synchronous) + :: (KnownNat n, Default a, Undefined a, HiddenClockReset domain gated synchronous) => Signal domain a -- ^ Signal to create a window over -> Vec (n + 1) (Signal domain a) -- ^ Window of at least size 1 windowD = hideClockReset E.windowD diff --git a/src/Clash/Prelude/BlockRam.hs b/src/Clash/Prelude/BlockRam.hs index f55bf959ad..a49b359d80 100644 --- a/src/Clash/Prelude/BlockRam.hs +++ b/src/Clash/Prelude/BlockRam.hs @@ -18,7 +18,7 @@ We start with the definition of the Instructions, Register names and machine codes: @ -{\-\# LANGUAGE RecordWildCards, TupleSections \#-\} +{\-\# LANGUAGE RecordWildCards, TupleSections, DeriveAnyClass \#-\} module CPU where import Clash.Prelude @@ -44,7 +44,7 @@ data Reg | RegC | RegD | RegE - deriving (Eq,Show,Enum) + deriving (Eq,Show,Enum,Undefined) data Operator = Add | Sub | Incr | Imm | CmpGt deriving (Eq,Show) @@ -367,11 +367,12 @@ import qualified Clash.Explicit.BlockRam as E import Clash.Signal import Clash.Sized.Unsigned (Unsigned) import Clash.Sized.Vector (Vec) +import Clash.XException (Undefined) {- $setup >>> import Clash.Prelude as C >>> import qualified Data.List as L ->>> :set -XDataKinds -XRecordWildCards -XTupleSections -XTypeApplications -XFlexibleContexts +>>> :set -XDataKinds -XRecordWildCards -XTupleSections -XTypeApplications -XFlexibleContexts -XDeriveAnyClass >>> type InstrAddr = Unsigned 8 >>> type MemAddr = Unsigned 5 >>> type Value = Signed 8 @@ -384,7 +385,7 @@ data Reg | RegC | RegD | RegE - deriving (Eq,Show,Enum) + deriving (Eq,Show,Enum,Undefined) :} >>> :{ @@ -698,7 +699,7 @@ blockRamPow2 = \cnt rd wrM -> withFrozenCallStack -- ... => -- Signal domain addr -- -> Signal domain (Maybe (addr, a)) -> Signal domain a -readNew :: (Eq addr, HiddenClockReset domain gated synchronous) +readNew :: (Eq addr, Undefined a, HiddenClockReset domain gated synchronous) => (Signal domain addr -> Signal domain (Maybe (addr, a)) -> Signal domain a) -- ^ The @ram@ component -> Signal domain addr -- ^ Read address @r@ diff --git a/src/Clash/Prelude/DataFlow.hs b/src/Clash/Prelude/DataFlow.hs index 7fc666b9a0..dd30bbddd2 100644 --- a/src/Clash/Prelude/DataFlow.hs +++ b/src/Clash/Prelude/DataFlow.hs @@ -60,6 +60,7 @@ import Clash.Signal.Internal (clockGate, register#) import Clash.Explicit.Signal (Clock, Reset, Signal) import Clash.Sized.BitVector (BitVector) import Clash.Sized.Vector +import Clash.XException (Undefined) {- | Dataflow circuit with bidirectional synchronisation channels. @@ -148,7 +149,8 @@ pureDF f = DF (\i iV oR -> (fmap f i,iV,oR)) -- | Create a 'DataFlow' circuit from a Mealy machine description as those of -- "Clash.Prelude.Mealy" -mealyDF :: Clock domain gated +mealyDF :: Undefined s + => Clock domain gated -> Reset domain synchronous -> (s -> i -> (s,o)) -> s @@ -161,7 +163,8 @@ mealyDF clk rst f iS = -- | Create a 'DataFlow' circuit from a Moore machine description as those of -- "Clash.Prelude.Moore" -mooreDF :: Clock domain gated +mooreDF :: Undefined s + => Clock domain gated -> Reset domain synchronous -> (s -> i -> s) -> (s -> o) @@ -203,7 +206,7 @@ fifoDF_mealy (mem,rptr,wptr) (wdata,winc,rinc) = -- fifo4 = 'fifoDF' d4 (2 :> 3 :> Nil) -- @ fifoDF :: forall addrSize m n a domain gated synchronous . - (KnownNat addrSize, KnownNat n, KnownNat m, (m + n) ~ (2 ^ addrSize)) + (KnownNat addrSize, KnownNat n, KnownNat m, (m + n) ~ (2 ^ addrSize), Undefined a) => Clock domain gated -> Reset domain synchronous -> SNat (m + n) -- ^ Depth of the FIFO buffer. Must be a power of two. @@ -334,7 +337,7 @@ parNDF fs = -- @ -- -- <> -loopDF :: (KnownNat m, KnownNat n, KnownNat addrSize, (m+n) ~ (2^addrSize)) +loopDF :: (KnownNat m, KnownNat n, KnownNat addrSize, (m+n) ~ (2^addrSize), Undefined d) => Clock dom gated -> Reset dom synchronous -> SNat (m + n) -- ^ Depth of the FIFO buffer. Must be a power of two diff --git a/src/Clash/Prelude/Mealy.hs b/src/Clash/Prelude/Mealy.hs index 5d7c5d1acd..31ee5e0e62 100644 --- a/src/Clash/Prelude/Mealy.hs +++ b/src/Clash/Prelude/Mealy.hs @@ -25,6 +25,7 @@ where import qualified Clash.Explicit.Mealy as E import Clash.Signal +import Clash.XException {- $setup >>> :set -XDataKinds -XTypeApplications @@ -72,7 +73,7 @@ let macT s (x,y) = (s',s) -- s1 = 'mealy' mac 0 ('Clash.Signal.bundle' (a,x)) -- s2 = 'mealy' mac 0 ('Clash.Signal.bundle' (b,y)) -- @ -mealy :: HiddenClockReset domain gated synchronous +mealy :: (Undefined s, HiddenClockReset domain gated synchronous) => (s -> i -> (s,o)) -- ^ Transfer function in mealy machine form: -- @state -> input -> (newstate,output)@ -> s -- ^ Initial state @@ -108,7 +109,7 @@ mealy = hideClockReset E.mealy -- (i1,b1) = 'mealyB' f 0 (a,b) -- (i2,b2) = 'mealyB' f 3 (i1,c) -- @ -mealyB :: (Bundle i, Bundle o, HiddenClockReset domain gated synchronous) +mealyB :: (Bundle i, Bundle o, Undefined s, HiddenClockReset domain gated synchronous) => (s -> i -> (s,o)) -- ^ Transfer function in mealy machine form: -- @state -> input -> (newstate,output)@ -> s -- ^ Initial state @@ -119,7 +120,7 @@ mealyB = hideClockReset E.mealyB {-# INLINE mealyB #-} -- | Infix version of 'mealyB' -(<^>) :: (Bundle i, Bundle o, HiddenClockReset domain gated synchronous) +(<^>) :: (Bundle i, Bundle o, Undefined s, HiddenClockReset domain gated synchronous) => (s -> i -> (s,o)) -- ^ Transfer function in mealy machine form: -- @state -> input -> (newstate,output)@ -> s -- ^ Initial state diff --git a/src/Clash/Prelude/Moore.hs b/src/Clash/Prelude/Moore.hs index 4d82d67187..363c18305e 100644 --- a/src/Clash/Prelude/Moore.hs +++ b/src/Clash/Prelude/Moore.hs @@ -26,6 +26,7 @@ where import qualified Clash.Explicit.Moore as E import Clash.Signal +import Clash.XException {- $setup >>> :set -XDataKinds -XTypeApplications @@ -70,7 +71,7 @@ let macT s (x,y) = x * y + s -- s2 = 'moore' mac id 0 ('Clash.Signal.bundle' (b,y)) -- @ moore - :: HiddenClockReset domain gated synchronous + :: (Undefined s, HiddenClockReset domain gated synchronous) => (s -> i -> s) -- ^ Transfer function in moore machine form: -- @state -> input -> newstate@ -> (s -> o) -- ^ Output function in moore machine form: @@ -86,7 +87,7 @@ moore = hideClockReset E.moore -- | Create a synchronous function from a combinational function describing -- a moore machine without any output logic medvedev - :: HiddenClockReset domain gated synchronous + :: (Undefined s, HiddenClockReset domain gated synchronous) => (s -> i -> s) -> s -> (Signal domain i -> Signal domain s) @@ -121,7 +122,7 @@ medvedev tr st = moore tr id st -- (i2,b2) = 'mooreB' t o 3 (i1,c) -- @ mooreB - :: (Bundle i, Bundle o,HiddenClockReset domain gated synchronous) + :: (Bundle i, Bundle o, Undefined s, HiddenClockReset domain gated synchronous) => (s -> i -> s) -- ^ Transfer function in moore machine form: -- @state -> input -> newstate@ -> (s -> o) -- ^ Output function in moore machine form: @@ -135,7 +136,7 @@ mooreB = hideClockReset E.mooreB -- | A version of 'medvedev' that does automatic 'Bundle'ing medvedevB - :: (Bundle i, Bundle s, HiddenClockReset domain gated synchronous) + :: (Bundle i, Bundle s, Undefined s, HiddenClockReset domain gated synchronous) => (s -> i -> s) -> s -> (Unbundled domain i -> Unbundled domain s) diff --git a/src/Clash/Prelude/Safe.hs b/src/Clash/Prelude/Safe.hs index 267f0f8a09..bb23e7e31f 100644 --- a/src/Clash/Prelude/Safe.hs +++ b/src/Clash/Prelude/Safe.hs @@ -179,7 +179,7 @@ It instead exports the identically named functions defined in terms of -- [(8,8),(1,1),(2,2),(3,3)... -- ... registerB - :: (HiddenClockReset domain gated synchronous, Bundle a) + :: (Bundle a, Undefined a, HiddenClockReset domain gated synchronous) => a -> Unbundled domain a -> Unbundled domain a @@ -189,7 +189,7 @@ infixr 3 `registerB` -- | Give a pulse when the 'Signal' goes from 'minBound' to 'maxBound' isRising - :: (HiddenClockReset domain gated synchronous, Bounded a, Eq a) + :: (Bounded a, Eq a, Undefined a, HiddenClockReset domain gated synchronous) => a -- ^ Starting value -> Signal domain a -> Signal domain Bool @@ -198,7 +198,7 @@ isRising = hideClockReset E.isRising -- | Give a pulse when the 'Signal' goes from 'maxBound' to 'minBound' isFalling - :: (HiddenClockReset domain gated synchronous, Bounded a, Eq a) + :: (Bounded a, Eq a, Undefined a, HiddenClockReset domain gated synchronous) => a -- ^ Starting value -> Signal domain a -> Signal domain Bool diff --git a/src/Clash/Signal.hs b/src/Clash/Signal.hs index ebf45f2553..c4f12e7129 100644 --- a/src/Clash/Signal.hs +++ b/src/Clash/Signal.hs @@ -147,6 +147,7 @@ import Clash.Signal.Bundle (Bundle (..)) import Clash.Signal.Internal hiding (sample, sample_lazy, sampleN, sampleN_lazy, simulate, simulate_lazy, testFor) import qualified Clash.Signal.Internal as S +import Clash.XException (Undefined) {- $setup >>> :set -XFlexibleContexts -XTypeApplications @@ -462,7 +463,7 @@ withClockReset = \clk rst f -> expose @"rst" (expose @"clk" f clk) rst -- >>> printX (sampleN 3 (delay (fromList [1,2,3,4]))) -- [X,1,2] delay - :: (HiddenClock domain gated, HasCallStack) + :: (HasCallStack, Undefined a, HiddenClock domain gated) => Signal domain a -- ^ Signal to delay -> Signal domain a @@ -475,7 +476,7 @@ delay = \i -> withFrozenCallStack (delay# #clk i) -- >>> sampleN 3 (register 8 (fromList [1,2,3,4])) -- [8,1,2] register - :: (HiddenClockReset domain gated synchronous, HasCallStack) + :: (HasCallStack, Undefined a, HiddenClockReset domain gated synchronous) => a -- ^ Reset value -- @@ -509,7 +510,7 @@ infixr 3 `register` -- >>> sampleN 8 countSometimes -- [0,0,1,1,2,2,3,3] regMaybe - :: (HiddenClockReset domain gated synchronous, HasCallStack) + :: (HasCallStack, Undefined a, HiddenClockReset domain gated synchronous) => a -- ^ Reset value -- @@ -537,7 +538,7 @@ infixr 3 `regMaybe` -- >>> sampleN 8 count -- [0,0,1,1,2,2,3,3] regEn - :: (HiddenClockReset domain gated synchronous, HasCallStack) + :: (HasCallStack, Undefined a, HiddenClockReset domain gated synchronous) => a -- ^ Reset value -- diff --git a/src/Clash/Signal/Delayed.hs b/src/Clash/Signal/Delayed.hs index b1104bd487..de52554415 100644 --- a/src/Clash/Signal/Delayed.hs +++ b/src/Clash/Signal/Delayed.hs @@ -43,6 +43,7 @@ import Clash.Explicit.Signal.Delayed import Clash.Sized.Vector (Vec) import Clash.Signal (HiddenClockReset, hideClockReset) +import Clash.XException {- $setup >>> :set -XDataKinds -XTypeOperators -XTypeApplications -XFlexibleContexts @@ -61,7 +62,7 @@ import Clash.Signal -- >>> sampleN 6 (toSignal (delay3 (dfromList [1..]))) -- [0,0,0,1,2,3] delayed - :: (KnownNat d, HiddenClockReset domain gated synchronous) + :: (KnownNat d, Undefined a, HiddenClockReset domain gated synchronous) => Vec d a -> DSignal domain n a -> DSignal domain (n + d) a @@ -77,7 +78,7 @@ delayed = hideClockReset E.delayed -- >>> sampleN 6 (toSignal (delay2 (dfromList [1..]))) -- [0,0,1,2,3,4] delayedI - :: (Default a, KnownNat d, HiddenClockReset domain gated synchronous) + :: (Default a, KnownNat d, Undefined a, HiddenClockReset domain gated synchronous) => DSignal domain n a -> DSignal domain (n + d) a delayedI = hideClockReset E.delayedI diff --git a/src/Clash/Signal/Internal.hs b/src/Clash/Signal/Internal.hs index ab52879fa8..ef800c7613 100644 --- a/src/Clash/Signal/Internal.hs +++ b/src/Clash/Signal/Internal.hs @@ -102,7 +102,7 @@ import Test.QuickCheck (Arbitrary (..), CoArbitrary(..), Property, import Clash.Promoted.Nat (SNat (..), snatToInteger, snatToNum) import Clash.Promoted.Symbol (SSymbol (..)) -import Clash.XException (XException, errorX, seqX) +import Clash.XException (Undefined (..), XException, errorX, seqX) {- $setup >>> :set -XDataKinds @@ -553,15 +553,15 @@ infixr 3 .&&. -- need to 'seq' it explicitly. delay# - :: HasCallStack + :: (HasCallStack, Undefined a) => Clock domain gated -> Signal domain a -> Signal domain a delay# Clock {} = - \s -> withFrozenCallStack (errorX "delay: initial value undefined") :- s + \s -> withFrozenCallStack (deepErrorX "delay: initial value undefined") :- s delay# (GatedClock _ _ en) = - go (withFrozenCallStack (errorX "delay: initial value undefined")) en + go (withFrozenCallStack (deepErrorX "delay: initial value undefined")) en where go o (e :- es) as@(~(x :- xs)) = -- See [Note: register strictness annotations] @@ -569,14 +569,14 @@ delay# (GatedClock _ _ en) = {-# NOINLINE delay# #-} register# - :: HasCallStack + :: (HasCallStack, Undefined a) => Clock domain gated -> Reset domain synchronous -> a -> Signal domain a -> Signal domain a register# Clock {} (Sync rst) i = - go (withFrozenCallStack (errorX "register: initial value undefined")) rst + go (withFrozenCallStack (deepErrorX "register: initial value undefined")) rst where go o rt@(~(r :- rs)) as@(~(x :- xs)) = let o' = if r then i else x @@ -584,7 +584,7 @@ register# Clock {} (Sync rst) i = in o `seqX` o :- (rt `seq` as `seq` go o' rs xs) register# Clock {} (Async rst) i = - go (withFrozenCallStack (errorX "register: initial value undefined")) rst + go (withFrozenCallStack (deepErrorX "register: initial value undefined")) rst where go o (r :- rs) as@(~(x :- xs)) = let o' = if r then i else o @@ -592,7 +592,7 @@ register# Clock {} (Async rst) i = in o' `seqX` o' :- (as `seq` go x rs xs) register# (GatedClock _ _ ena) (Sync rst) i = - go (withFrozenCallStack (errorX "register: initial value undefined")) rst ena + go (withFrozenCallStack (deepErrorX "register: initial value undefined")) rst ena where go o rt@(~(r :- rs)) enas@(~(e :- es)) as@(~(x :- xs)) = let oE = if e then x else o @@ -601,7 +601,7 @@ register# (GatedClock _ _ ena) (Sync rst) i = in o `seqX` o :- (rt `seq` enas `seq` as `seq` go oR rs es xs) register# (GatedClock _ _ ena) (Async rst) i = - go (withFrozenCallStack (errorX "register: initial value undefined")) rst ena + go (withFrozenCallStack (deepErrorX "register: initial value undefined")) rst ena where go o (r :- rs) enas@(~(e :- es)) as@(~(x :- xs)) = let oR = if r then i else o diff --git a/src/Clash/Sized/Fixed.hs b/src/Clash/Sized/Fixed.hs index 34998648ba..052f142c2c 100644 --- a/src/Clash/Sized/Fixed.hs +++ b/src/Clash/Sized/Fixed.hs @@ -98,7 +98,7 @@ import Clash.Prelude.BitReduction (reduceAnd, reduceOr) import Clash.Sized.BitVector (BitVector, (++#)) import Clash.Sized.Signed (Signed) import Clash.Sized.Unsigned (Unsigned) -import Clash.XException (ShowX (..), showsPrecXWith) +import Clash.XException (ShowX (..), Undefined, showsPrecXWith) {- $setup >>> :set -XDataKinds @@ -122,6 +122,8 @@ import Clash.XException (ShowX (..), showsPrecXWith) newtype Fixed (rep :: Nat -> *) (int :: Nat) (frac :: Nat) = Fixed { unFixed :: rep (int + frac) } +instance Undefined (Fixed rep int frac) + deriving instance NFData (rep (int + frac)) => NFData (Fixed rep int frac) deriving instance (Typeable rep, Typeable int, Typeable frac , Data (rep (int + frac))) => Data (Fixed rep int frac) diff --git a/src/Clash/Sized/Internal/BitVector.hs b/src/Clash/Sized/Internal/BitVector.hs index 6f2af22fc2..2a924ef287 100644 --- a/src/Clash/Sized/Internal/BitVector.hs +++ b/src/Clash/Sized/Internal/BitVector.hs @@ -7,7 +7,7 @@ Maintainer : Christiaan Baaij {-# LANGUAGE DataKinds #-} {-# LANGUAGE DeriveDataTypeable #-} -{-# LANGUAGE GeneralizedNewtypeDeriving #-} +{-# LANGUAGE DeriveAnyClass #-} {-# LANGUAGE KindSignatures #-} {-# LANGUAGE MagicHash #-} {-# LANGUAGE MultiParamTypeClasses #-} @@ -144,7 +144,7 @@ import Clash.Class.Num (ExtendingNum (..), SaturatingNum (..), SaturationMode (..)) import Clash.Class.Resize (Resize (..)) import Clash.Promoted.Nat (SNat, snatToInteger, snatToNum) -import Clash.XException (ShowX (..), showsPrecXWith) +import Clash.XException (ShowX (..), Undefined, showsPrecXWith) import {-# SOURCE #-} qualified Clash.Sized.Vector as V import {-# SOURCE #-} qualified Clash.Sized.Internal.Index as I @@ -164,7 +164,7 @@ newtype BitVector (n :: Nat) = -- | The constructor, 'BV', and the field, 'unsafeToInteger', are not -- synthesisable. BV { unsafeToInteger :: Integer} - deriving (Data) + deriving (Data,Undefined) -- * Bit @@ -173,7 +173,7 @@ newtype Bit = -- | The constructor, 'Bit', and the field, 'unsafeToInteger#', are not -- synthesisable. Bit { unsafeToInteger# :: Integer} - deriving (Data) + deriving (Data,Undefined) -- * Constructions -- ** Initialisation diff --git a/src/Clash/Sized/Internal/Index.hs b/src/Clash/Sized/Internal/Index.hs index cbcea16994..a04479fa32 100644 --- a/src/Clash/Sized/Internal/Index.hs +++ b/src/Clash/Sized/Internal/Index.hs @@ -6,6 +6,7 @@ Maintainer : Christiaan Baaij -} {-# LANGUAGE DataKinds #-} +{-# LANGUAGE DeriveAnyClass #-} {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE KindSignatures #-} {-# LANGUAGE MagicHash #-} @@ -86,7 +87,7 @@ import Clash.Class.Num (ExtendingNum (..), SaturatingNum (..), import Clash.Class.Resize (Resize (..)) import {-# SOURCE #-} Clash.Sized.Internal.BitVector (BitVector (BV)) import Clash.Promoted.Nat (SNat, snatToNum, leToPlusKN) -import Clash.XException (ShowX (..), showsPrecXWith) +import Clash.XException (ShowX (..), Undefined, showsPrecXWith) -- | Arbitrary-bounded unsigned integer represented by @ceil(log_2(n))@ bits. -- @@ -115,7 +116,7 @@ newtype Index (n :: Nat) = -- | The constructor, 'I', and the field, 'unsafeToInteger', are not -- synthesisable. I { unsafeToInteger :: Integer } - deriving Data + deriving (Data,Undefined) instance NFData (Index n) where rnf (I i) = rnf i `seq` () diff --git a/src/Clash/Sized/Internal/Signed.hs b/src/Clash/Sized/Internal/Signed.hs index 41a478ea51..014897bbd0 100644 --- a/src/Clash/Sized/Internal/Signed.hs +++ b/src/Clash/Sized/Internal/Signed.hs @@ -6,8 +6,8 @@ Maintainer : Christiaan Baaij -} {-# LANGUAGE DataKinds #-} +{-# LANGUAGE DeriveAnyClass #-} {-# LANGUAGE DeriveDataTypeable #-} -{-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE KindSignatures #-} {-# LANGUAGE MagicHash #-} {-# LANGUAGE MultiParamTypeClasses #-} @@ -107,7 +107,7 @@ import Clash.Prelude.BitIndex ((!), msb, replaceBit, split) import Clash.Prelude.BitReduction (reduceAnd, reduceOr) import Clash.Sized.Internal.BitVector (BitVector (BV), Bit, (++#), high, low) import qualified Clash.Sized.Internal.BitVector as BV -import Clash.XException (ShowX (..), showsPrecXWith) +import Clash.XException (ShowX (..), Undefined, showsPrecXWith) -- | Arbitrary-width signed integer represented by @n@ bits, including the sign -- bit. @@ -148,7 +148,7 @@ newtype Signed (n :: Nat) = -- | The constructor, 'S', and the field, 'unsafeToInteger', are not -- synthesisable. S { unsafeToInteger :: Integer} - deriving (Data) + deriving (Data, Undefined) {-# NOINLINE size# #-} size# :: KnownNat n => Signed n -> Int diff --git a/src/Clash/Sized/Internal/Unsigned.hs b/src/Clash/Sized/Internal/Unsigned.hs index fdc45f9cb1..083f311179 100644 --- a/src/Clash/Sized/Internal/Unsigned.hs +++ b/src/Clash/Sized/Internal/Unsigned.hs @@ -6,6 +6,7 @@ Maintainer : Christiaan Baaij -} {-# LANGUAGE DataKinds #-} +{-# LANGUAGE DeriveAnyClass #-} {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE MagicHash #-} {-# LANGUAGE MultiParamTypeClasses #-} @@ -98,7 +99,7 @@ import Clash.Prelude.BitIndex ((!), msb, replaceBit, split) import Clash.Prelude.BitReduction (reduceOr) import Clash.Sized.Internal.BitVector (BitVector (BV), Bit, high, low) import qualified Clash.Sized.Internal.BitVector as BV -import Clash.XException (ShowX (..), showsPrecXWith) +import Clash.XException (ShowX (..), Undefined, showsPrecXWith) -- | Arbitrary-width unsigned integer represented by @n@ bits -- @@ -135,7 +136,7 @@ newtype Unsigned (n :: Nat) = -- | The constructor, 'U', and the field, 'unsafeToInteger', are not -- synthesisable. U { unsafeToInteger :: Integer } - deriving Data + deriving (Data, Undefined) {-# NOINLINE size# #-} size# :: KnownNat n => Unsigned n -> Int diff --git a/src/Clash/Sized/RTree.hs b/src/Clash/Sized/RTree.hs index 13914cba11..b5249abe1c 100644 --- a/src/Clash/Sized/RTree.hs +++ b/src/Clash/Sized/RTree.hs @@ -73,7 +73,8 @@ import Clash.Promoted.Nat (SNat (..), UNat (..), pow2SNat, snatToNum, import Clash.Promoted.Nat.Literals (d1) import Clash.Sized.Index (Index) import Clash.Sized.Vector (Vec (..), (!!), (++), dtfold, replace) -import Clash.XException (ShowX (..), showsX, showsPrecXWith) +import Clash.XException + (ShowX (..), Undefined (..), showsX, showsPrecXWith) {- $setup >>> :set -XDataKinds @@ -213,6 +214,9 @@ instance (KnownNat d, Arbitrary a) => Arbitrary (RTree d a) where instance (KnownNat d, CoArbitrary a) => CoArbitrary (RTree d a) where coarbitrary = coarbitrary . toList +instance (KnownNat d, Undefined a) => Undefined (RTree d a) where + deepErrorX x = pure (deepErrorX x) + -- | A /dependently/ typed fold over trees. -- -- As an example of when you might want to use 'dtfold' we will build a diff --git a/src/Clash/Sized/Vector.hs b/src/Clash/Sized/Vector.hs index ff08a685a3..a9b7991010 100644 --- a/src/Clash/Sized/Vector.hs +++ b/src/Clash/Sized/Vector.hs @@ -131,7 +131,7 @@ import Clash.Sized.Internal.BitVector (Bit, BitVector, (++#), split#) import Clash.Sized.Index (Index) import Clash.Class.BitPack (BitPack (..)) -import Clash.XException (ShowX (..), showsX, showsPrecXWith) +import Clash.XException (ShowX (..), Undefined (..), showsX, showsPrecXWith) {- $setup >>> :set -XDataKinds @@ -300,6 +300,9 @@ traverse# f (x `Cons` xs) = Cons <$> f x <*> traverse# f xs instance (Default a, KnownNat n) => Default (Vec n a) where def = repeat def +instance (Undefined a, KnownNat n) => Undefined (Vec n a) where + deepErrorX x = repeat (deepErrorX x) + {-# INLINE singleton #-} -- | Create a vector of one element -- diff --git a/src/Clash/XException.hs b/src/Clash/XException.hs index 8c1b5e480e..48136e344c 100644 --- a/src/Clash/XException.hs +++ b/src/Clash/XException.hs @@ -34,14 +34,19 @@ module Clash.XException , ShowX (..), showsX, printX, showsPrecXWith -- * Strict evaluation , seqX + -- * Structured undefined + , Undefined (..) ) where import Control.Exception (Exception, catch, evaluate, throw) import Control.DeepSeq (NFData, rnf) import Data.Complex (Complex) +import Data.Foldable (toList) import Data.Int (Int8,Int16,Int32,Int64) +import Data.Ord (Down (Down)) import Data.Ratio (Ratio) +import Data.Sequence (Seq) import Data.Word (Word8,Word16,Word32,Word64) import GHC.Exts (Char (C#), Double (D#), Float (F#), Int (I#), Word (W#)) import GHC.Generics @@ -231,6 +236,9 @@ instance ShowX Bool instance ShowX Double where showsPrecX = showsPrecXWith showsPrec +instance ShowX a => ShowX (Down a) where + showsPrecX = showsPrecXWith showsPrecX + instance (ShowX a, ShowX b) => ShowX (Either a b) instance ShowX Float where @@ -254,6 +262,9 @@ instance ShowX Int64 where instance ShowX Integer where showsPrecX = showsPrecXWith showsPrec +instance ShowX a => ShowX (Seq a) where + showsPrecX _ = showListX . toList + instance ShowX Word where showsPrecX = showsPrecXWith showsPrec @@ -358,3 +369,114 @@ instance GShowX UInt where gshowsPrecX _ _ (UInt i) = showsPrec 0 (I# i) . showChar '#' instance GShowX UWord where gshowsPrecX _ _ (UWord w) = showsPrec 0 (W# w) . showString "##" + +-- | Create a value where all the elements have an 'errorX', but the spine +-- is defined. +class Undefined a where + -- | Create a value where all the elements have an 'errorX', but the spine + -- is defined. + deepErrorX :: HasCallStack => String -> a + deepErrorX = errorX + +instance Undefined () +instance (Undefined a, Undefined b) => Undefined (a,b) where + deepErrorX x = (deepErrorX x,deepErrorX x) +instance (Undefined a, Undefined b, Undefined c) => Undefined (a,b,c) where + deepErrorX x = (deepErrorX x,deepErrorX x,deepErrorX x) +instance (Undefined a, Undefined b, Undefined c, Undefined d) => + Undefined (a,b,c,d) where + deepErrorX x = (deepErrorX x,deepErrorX x,deepErrorX x,deepErrorX x) +instance (Undefined a, Undefined b, Undefined c, Undefined d, Undefined e) => + Undefined (a,b,c,d,e) where + deepErrorX x = (deepErrorX x,deepErrorX x,deepErrorX x,deepErrorX x + ,deepErrorX x) +instance (Undefined a, Undefined b, Undefined c, Undefined d, Undefined e + ,Undefined f) + => Undefined (a,b,c,d,e,f) where + deepErrorX x = (deepErrorX x,deepErrorX x,deepErrorX x,deepErrorX x + ,deepErrorX x,deepErrorX x) +instance (Undefined a, Undefined b, Undefined c, Undefined d, Undefined e + ,Undefined f, Undefined g) + => Undefined (a,b,c,d,e,f,g) where + deepErrorX x = (deepErrorX x,deepErrorX x,deepErrorX x,deepErrorX x + ,deepErrorX x,deepErrorX x,deepErrorX x) +instance (Undefined a, Undefined b, Undefined c, Undefined d, Undefined e + ,Undefined f, Undefined g, Undefined h) + => Undefined (a,b,c,d,e,f,g,h) where + deepErrorX x = (deepErrorX x,deepErrorX x,deepErrorX x,deepErrorX x + ,deepErrorX x,deepErrorX x,deepErrorX x,deepErrorX x) +instance (Undefined a, Undefined b, Undefined c, Undefined d, Undefined e + ,Undefined f, Undefined g, Undefined h, Undefined i) + => Undefined (a,b,c,d,e,f,g,h,i) where + deepErrorX x = (deepErrorX x,deepErrorX x,deepErrorX x,deepErrorX x + ,deepErrorX x,deepErrorX x,deepErrorX x,deepErrorX x + ,deepErrorX x) +instance (Undefined a, Undefined b, Undefined c, Undefined d, Undefined e + ,Undefined f, Undefined g, Undefined h, Undefined i, Undefined j) + => Undefined (a,b,c,d,e,f,g,h,i,j) where + deepErrorX x = (deepErrorX x,deepErrorX x,deepErrorX x,deepErrorX x + ,deepErrorX x,deepErrorX x,deepErrorX x,deepErrorX x + ,deepErrorX x,deepErrorX x) +instance (Undefined a, Undefined b, Undefined c, Undefined d, Undefined e + ,Undefined f, Undefined g, Undefined h, Undefined i, Undefined j + ,Undefined k) + => Undefined (a,b,c,d,e,f,g,h,i,j,k) where + deepErrorX x = (deepErrorX x,deepErrorX x,deepErrorX x,deepErrorX x + ,deepErrorX x,deepErrorX x,deepErrorX x,deepErrorX x + ,deepErrorX x,deepErrorX x,deepErrorX x) +instance (Undefined a, Undefined b, Undefined c, Undefined d, Undefined e + ,Undefined f, Undefined g, Undefined h, Undefined i, Undefined j + ,Undefined k, Undefined l) + => Undefined (a,b,c,d,e,f,g,h,i,j,k,l) where + deepErrorX x = (deepErrorX x,deepErrorX x,deepErrorX x,deepErrorX x + ,deepErrorX x,deepErrorX x,deepErrorX x,deepErrorX x + ,deepErrorX x,deepErrorX x,deepErrorX x,deepErrorX x) +instance (Undefined a, Undefined b, Undefined c, Undefined d, Undefined e + ,Undefined f, Undefined g, Undefined h, Undefined i, Undefined j + ,Undefined k, Undefined l, Undefined m) + => Undefined (a,b,c,d,e,f,g,h,i,j,k,l,m) where + deepErrorX x = (deepErrorX x,deepErrorX x,deepErrorX x,deepErrorX x + ,deepErrorX x,deepErrorX x,deepErrorX x,deepErrorX x + ,deepErrorX x,deepErrorX x,deepErrorX x,deepErrorX x + ,deepErrorX x) +instance (Undefined a, Undefined b, Undefined c, Undefined d, Undefined e + ,Undefined f, Undefined g, Undefined h, Undefined i, Undefined j + ,Undefined k, Undefined l, Undefined m, Undefined n) + => Undefined (a,b,c,d,e,f,g,h,i,j,k,l,m,n) where + deepErrorX x = (deepErrorX x,deepErrorX x,deepErrorX x,deepErrorX x + ,deepErrorX x,deepErrorX x,deepErrorX x,deepErrorX x + ,deepErrorX x,deepErrorX x,deepErrorX x,deepErrorX x + ,deepErrorX x,deepErrorX x) +instance (Undefined a, Undefined b, Undefined c, Undefined d, Undefined e + ,Undefined f, Undefined g, Undefined h, Undefined i, Undefined j + ,Undefined k, Undefined l, Undefined m, Undefined n, Undefined o) + => Undefined (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o) where + deepErrorX x = (deepErrorX x,deepErrorX x,deepErrorX x,deepErrorX x + ,deepErrorX x,deepErrorX x,deepErrorX x,deepErrorX x + ,deepErrorX x,deepErrorX x,deepErrorX x,deepErrorX x + ,deepErrorX x,deepErrorX x,deepErrorX x) + +instance Undefined a => Undefined (Down a) where + deepErrorX = Down . deepErrorX + +instance Undefined [a] +instance Undefined Char +instance Undefined Bool +instance Undefined Double +instance Undefined (Either a b) +instance Undefined Float +instance Undefined Int +instance Undefined Int8 +instance Undefined Int16 +instance Undefined Int32 +instance Undefined Int64 +instance Undefined Integer +instance Undefined (Seq a) +instance Undefined Word +instance Undefined Word8 +instance Undefined Word16 +instance Undefined Word32 +instance Undefined Word64 +instance Undefined (Maybe a) +instance Undefined (Ratio a) +instance Undefined (Complex a)