playground/clash/fsm.hs

42 lines
602 B
Haskell

module FSM where
import Clash.Prelude
import qualified Prelude
data Point a =
Pt (a -> Bool)
| Yes
| No
getPtFn :: Point a -> (a -> Bool)
getPtFn p = case p of
Pt f -> f
Yes -> \x -> True
No -> \x -> False
-- getPtFn (Pt f) = f
-- getPtFn Yes = \x -> True
-- getPtFn No = \x -> False
type State = [Point]
-- [Pt 0, Pt 1, Pt 2]
points = map Pt $ map (==) [0, 1, 2]
-- ssyes =
-- [[Pt 1, Pt 2, Yes],
-- [Yes],
-- [Pt 2, Yes]]
ssyes =
[[points!!1, points!!2, Yes],
[Yes],
[points!!2, Yes]]
sno = [No] >>= replicate 3
one
:: Eq a
=> Point
-> a
-> State