Skip to content

Change Signal.fromList's tail from errorX to error #2620

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion clash-prelude/src/Clash/Explicit/Prelude.hs
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ window clk rst en x = res
-- @
--
-- >>> simulateB (windowD3 systemClockGen resetGen enableGen) [1::Int,1,2,3,4] :: [Vec 3 Int]
-- [0 :> 0 :> 0 :> Nil,0 :> 0 :> 0 :> Nil,1 :> 0 :> 0 :> Nil,2 :> 1 :> 0 :> Nil,3 :> 2 :> 1 :> Nil,4 :> 3 :> 2 :> Nil,...
-- [0 :> 0 :> 0 :> Nil,0 :> 0 :> 0 :> Nil,1 :> 0 :> 0 :> Nil,2 :> 1 :> 0 :> Nil,3 :> 2 :> 1 :> Nil,4 :> 3 :> 2 :> Nil...
-- ...
windowD
:: ( KnownNat n
Expand Down
4 changes: 2 additions & 2 deletions clash-prelude/src/Clash/Prelude.hs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ functions a type class called 'Clash.Class.Parity.Parity' is available at
-- > window4 = window
--
-- >>> simulateB @System window4 [1::Int,2,3,4,5] :: [Vec 4 Int]
-- [1 :> 0 :> 0 :> 0 :> Nil,2 :> 1 :> 0 :> 0 :> Nil,3 :> 2 :> 1 :> 0 :> Nil,4 :> 3 :> 2 :> 1 :> Nil,5 :> 4 :> 3 :> 2 :> Nil,...
-- [1 :> 0 :> 0 :> 0 :> Nil,2 :> 1 :> 0 :> 0 :> Nil,3 :> 2 :> 1 :> 0 :> Nil,4 :> 3 :> 2 :> 1 :> Nil,5 :> 4 :> 3 :> 2 :> Nil...
-- ...
window
:: ( HiddenClockResetEnable dom
Expand All @@ -267,7 +267,7 @@ window = hideClockResetEnable E.window
-- > windowD3 = windowD
--
-- >>> simulateB @System windowD3 [1::Int,2,3,4] :: [Vec 3 Int]
-- [0 :> 0 :> 0 :> Nil,1 :> 0 :> 0 :> Nil,2 :> 1 :> 0 :> Nil,3 :> 2 :> 1 :> Nil,4 :> 3 :> 2 :> Nil,...
-- [0 :> 0 :> 0 :> Nil,1 :> 0 :> 0 :> Nil,2 :> 1 :> 0 :> Nil,3 :> 2 :> 1 :> Nil,4 :> 3 :> 2 :> Nil...
-- ...
windowD
:: ( HiddenClockResetEnable dom
Expand Down
2 changes: 1 addition & 1 deletion clash-prelude/src/Clash/Prelude/Moore.hs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ let macT s (x,y) = x * y + s
-- @
--
-- >>> simulate @System mac [(0,0),(1,1),(2,2),(3,3),(4,4)]
-- [0,0,1,5,14,30,...
-- [0,0,1,5,14,30...
-- ...
--
-- Synchronous sequential functions can be composed just like their
Expand Down
10 changes: 5 additions & 5 deletions clash-prelude/src/Clash/Signal/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ import Clash.NamedTypes
import Clash.Promoted.Nat (SNat (..), snatToNum, snatToNatural)
import Clash.Promoted.Symbol (SSymbol (..), ssymbolToString)
import Clash.XException
(NFDataX(..), errorX, isX, deepseqX, defaultSeqX, seqX)
(NFDataX(..), isX, deepseqX, defaultSeqX, seqX)

{- $setup
>>> :set -XDataKinds
Expand Down Expand Up @@ -1689,8 +1689,8 @@ sampleN n = take n . sample
-- [1,2]
--
-- __NB__: This function is not synthesizable
fromList :: NFDataX a => [a] -> Signal dom a
fromList = Prelude.foldr (\a b -> deepseqX a (a :- b)) (errorX "finite list")
fromList :: (HasCallStack,NFDataX a) => [a] -> Signal dom a
fromList = Prelude.foldr (\a b -> deepseqX a (a :- b)) (pure $ error "finite list")

-- * Simulation functions (not synthesizable)

Expand Down Expand Up @@ -1748,8 +1748,8 @@ sampleN_lazy n = take n . sample_lazy
-- [1,2]
--
-- __NB__: This function is not synthesizable
fromList_lazy :: [a] -> Signal dom a
fromList_lazy = Prelude.foldr (:-) (error "finite list")
fromList_lazy :: HasCallStack => [a] -> Signal dom a
fromList_lazy = Prelude.foldr (:-) (pure $ error "finite list")

-- * Simulation functions (not synthesizable)

Expand Down