playground/clash/FuncSynth-State.hs

78 lines
2.4 KiB
Haskell

-- Trying to see if a function type is synthesizable when enclosed
-- within a type with NFDataX
--
-- Verdict: No, it isn't (compiles though).
import Clash.Prelude
data Foo
= Foo (Int -> Bool)
deriving (Generic, NFDataX)
tf :: Foo -> Int -> (Foo, Bool)
tf (Foo f) inp = (s', out)
where
out = f inp
s' = Foo $ \x -> not $ f x
mon
:: SystemClockResetEnable
=> Signal System Int
-> Signal System Bool
mon = mealy tf $ Foo (\x -> True)
topEntity
:: Clock System
-> Reset System
-> Enable System
-> Signal System Int
-> Signal System Bool
topEntity = exposeClockResetEnable mon
{-
GHC: Setting up GHC took: 0.688s
GHC: Compiling and loading modules took: 0.970s
Clash: Parsing and compiling primitives took 0.203s
GHC+Clash: Loading modules cumulatively took 2.085s
Clash: Compiling Main.topEntity
Clash.Normalize.Transformations.Inline(523): InlineNonRep: c$Main.mon_ds[19] already inlined 20 times in: Main.mon[8214565720323816241]
. The type of the subject is:
GHC.Tuple.(,)[3746994889972252676]
Main.Foo[8214565720323816238]
GHC.Types.Bool[3674937295934324744]
Function Main.mon[8214565720323816241] will not reach a normal form and compilation
might fail.
Run with '-fclash-inline-limit=N' to increase the inline limit to N.
Clash.Normalize.Transformations.Inline(523): InlineNonRep: c$Main.mon_ds[19] already inlined 20 times in: Main.mon[8214565720323816241]
. The type of the subject is:
GHC.Tuple.(,)[3746994889972252676]
Main.Foo[8214565720323816238]
GHC.Types.Bool[3674937295934324744]
Function Main.mon[8214565720323816241] will not reach a normal form and compilation
might fail.
Run with '-fclash-inline-limit=N' to increase the inline limit to N.
Clash.Normalize.Transformations.Inline(523): InlineNonRep: c$Main.mon_ds[19] already inlined 20 times in: Main.mon[8214565720323816241]
. The type of the subject is:
GHC.Tuple.(,)[3746994889972252676]
Main.Foo[8214565720323816238]
GHC.Types.Bool[3674937295934324744]
Function Main.mon[8214565720323816241] will not reach a normal form and compilation
might fail.
Run with '-fclash-inline-limit=N' to increase the inline limit to N.
<no location info>: error:
Clash error call:
Clash.Core.Type(395): Report as bug: not a FunTy
CallStack (from HasCallStack):
error, called at src/Clash/Core/Type.hs:395:20 in clash-lib-1.6.3-4vM2gwSsWPHufxjlmfu4S:Clash.Core.Type
-}