From 7fa10a9a07c7160531baf595d1111277c17a38b2 Mon Sep 17 00:00:00 2001 From: Tom Smeding Date: Tue, 25 Feb 2025 23:56:16 +0100 Subject: Compile: Emit structs in proper order --- src/Data.hs | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/Data.hs') diff --git a/src/Data.hs b/src/Data.hs index 0be9046..8005737 100644 --- a/src/Data.hs +++ b/src/Data.hs @@ -77,6 +77,14 @@ fromSNat :: SNat n -> Int fromSNat SZ = 0 fromSNat (SS n) = succ (fromSNat n) +unSNat :: SNat n -> Nat +unSNat SZ = Z +unSNat (SS n) = S (unSNat n) + +fromNat :: Nat -> Int +fromNat Z = 0 +fromNat (S m) = succ (fromNat m) + class KnownNat n where knownNat :: SNat n instance KnownNat Z where knownNat = SZ instance KnownNat n => KnownNat (S n) where knownNat = SS knownNat @@ -124,6 +132,7 @@ unsafeCoerceRefl = unsafeCoerce Refl data Bag t = BNone | BOne t | BTwo (Bag t) (Bag t) | BMany [Bag t] deriving (Show, Functor, Foldable, Traversable) +-- | This instance is mostly there just for 'pure' instance Applicative Bag where pure = BOne BNone <*> _ = BNone -- cgit v1.2.3-70-g09d2