Created
April 16, 2018 16:17
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE FlexibleInstances #-} | |
module HKDClash where | |
import Clash.Prelude | |
import Data.Functor.Identity | |
type family HKD f a where | |
HKD Identity a = a | |
HKD f a = f a | |
data Person' f = Person | |
{ pName :: HKD f Bool | |
, pAge :: HKD f Int | |
} | |
type Person = Person' Identity | |
instance Bundle (Person' Identity) where | |
type Unbundled dom (Person' Identity) = Person' (Signal dom) | |
bundle (Person a b) = Person <$> a <*> b | |
unbundle p = Person (pName <$> p) (pAge <$> p) | |
topEntity | |
:: SystemClockReset | |
=> Signal System Person | |
-> Signal System Person | |
topEntity p = | |
let Person a b = unbundle p | |
b' = register 0 (b + 1) | |
in bundle (Person a b') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment