Skip to content

Instantly share code, notes, and snippets.

@BekaValentine
Created September 30, 2016 23:52
Show Gist options
  • Select an option

  • Save BekaValentine/044eee7861e3393aa72bdd822d47e9c8 to your computer and use it in GitHub Desktop.

Select an option

Save BekaValentine/044eee7861e3393aa72bdd822d47e9c8 to your computer and use it in GitHub Desktop.
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
module Serialization where
data Nat = Zero | Suc Nat
data family Frame (s :: [*]) (s' :: [*])
infixr :.
data Stack (s :: [*]) where
Done :: Stack '[]
(:.) :: Frame s s' -> Stack s' -> Stack s
data instance Frame (Bool ': s) s' where
TrueS :: Frame (Bool ': s) s
FalseS :: Frame (Bool ': s) s
data instance Frame (Nat ': s) s' where
ZeroS :: Frame (Nat ': s) s
SucS :: Frame (Nat ': s) (Nat ': s)
data instance Frame ((a,b) ': s) s' where
PairS :: Frame ((a,b) ': s) (a ': b ': s)
data instance Frame ([a] ': s) s' where
NilS :: Frame ([a] ': s) s
ConsS :: Frame ([a] ': s) (a ': [a] ': s)
s :: Stack '[[(Nat,Bool)]]
s =
ConsS :.
PairS :.
SucS :.
ZeroS :.
TrueS :.
ConsS :.
PairS :.
ZeroS :.
FalseS :.
NilS :.
Done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment