summaryrefslogtreecommitdiff
path: root/test/Main.hs
diff options
context:
space:
mode:
authorTom Smeding <tom@tomsmeding.com>2024-09-11 21:05:36 +0200
committerTom Smeding <tom@tomsmeding.com>2024-09-11 21:05:36 +0200
commitd0325149f93f6553c766622352a8eaae41b6cd3b (patch)
tree2f225a9654f405873b4976d04923d8c17301aefd /test/Main.hs
parent1372ecf48af80e7f795b1b1c11d6a63b5235bd77 (diff)
Allow some manual testing at the very least
Diffstat (limited to 'test/Main.hs')
-rw-r--r--test/Main.hs38
1 files changed, 38 insertions, 0 deletions
diff --git a/test/Main.hs b/test/Main.hs
new file mode 100644
index 0000000..19f56e2
--- /dev/null
+++ b/test/Main.hs
@@ -0,0 +1,38 @@
+{-# LANGUAGE DataKinds #-}
+{-# LANGUAGE GADTs #-}
+{-# LANGUAGE LambdaCase #-}
+{-# LANGUAGE StandaloneDeriving #-}
+{-# LANGUAGE TypeApplications #-}
+{-# LANGUAGE TypeFamilies #-}
+module Main where
+
+import qualified Data.Dependent.EnumMap.Strict as DE
+import Data.Dependent.Sum
+import Data.Some
+
+
+data Tag = A | B | C
+ deriving (Show)
+
+data STag tag where
+ SA :: STag A
+ SB :: STag B
+ SC :: STag C
+deriving instance Show (STag tag)
+
+instance DE.Enum1 STag where
+ type Enum1Info STag = ()
+ fromEnum1 = \case { SA -> (0, ()); SB -> (1, ()); SC -> (2, ()) }
+ toEnum1 n () = case n of { 0 -> Some SA; 1 -> Some SB; 2 -> Some SC; _ -> error "invalid tag" }
+
+data Value tag where
+ VA :: Int -> Value A
+ VB :: Bool -> Value B
+ VC :: String -> Value c
+deriving instance Show (Value tag)
+
+
+main :: IO ()
+main = do
+ print $ DE.fromList @STag @Value []
+ print $ DE.fromList [SB :=> VB False, SA :=> VA 3]