summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/Main.hs16
1 files changed, 12 insertions, 4 deletions
diff --git a/test/Main.hs b/test/Main.hs
index 209b88e..37e75b3 100644
--- a/test/Main.hs
+++ b/test/Main.hs
@@ -8,8 +8,9 @@
module Main where
import Data.Dependent.EnumMap.Strict qualified as DE
+import Data.Dependent.EnumMap.Strict.Internal (coe1)
import Data.Dependent.Sum
-
+import Data.Functor.Const
data Tag = A | B | C
deriving (Show)
@@ -21,9 +22,16 @@ data STag tag where
deriving instance Show (STag tag)
instance DE.Enum1 STag where
- type Enum1Info STag = STag
- fromEnum1 = \case { SA -> (0, SA); SB -> (1, SB); SC -> (2, SC) }
- toEnum1 n t = case (n, t) of { (0, SA) -> SA; (1, SB) -> SB; (2, SC) -> SC; _ -> error "invalid tag" }
+ type Enum1Info STag = Const ()
+ fromEnum1 = \case
+ SA -> (0, Const ())
+ SB -> (1, Const ())
+ SC -> (2, Const ())
+ toEnum1 n _ = case n of
+ 0 -> coe1 SA
+ 1 -> coe1 SB
+ 2 -> coe1 SC
+ _ -> error "invalid tag"
data Value tag where
VA :: Int -> Value A