-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSimplest.hs
38 lines (26 loc) · 1011 Bytes
/
Simplest.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
{-# LANGUAGE GADTs #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE MultiParamTypeClasses #-}
module Main where
import Data.Generic.Diff
data Simplest = No | Yes
-- The second step is creating the family datatype. Each constructor
-- in the datatypes above gets a constructor in a family GADT:
data SimplestFamily :: * -> * -> * where
No' :: SimplestFamily Simplest Nil
Yes' :: SimplestFamily Simplest Nil
instance Family SimplestFamily where
decEq No' No' = Just (Refl, Refl)
decEq Yes' Yes' = Just (Refl, Refl)
decEq _ _ = Nothing
fields No' No = Just CNil
fields Yes' Yes = Just CNil
fields _ _ = Nothing
apply No' CNil = No
apply Yes' CNil = Yes
string No' = "No"
string Yes' = "Yes"
instance Type SimplestFamily Simplest where
constructors = [Concr No', Concr Yes']
test :: EditScript SimplestFamily Simplest Simplest
test = diff No Yes