Skip to content

Instantly share code, notes, and snippets.

@christiaanb
Created April 16, 2018 16:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save christiaanb/d150b83fba69f6078dce82052ae4e2d6 to your computer and use it in GitHub Desktop.
Save christiaanb/d150b83fba69f6078dce82052ae4e2d6 to your computer and use it in GitHub Desktop.
{-# 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