eliminators 0.3 → 0.4
raw patch · 9 files changed
+38/−37 lines, 9 filesdep ~basedep ~singleton-natsdep ~singletonsPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: base, singleton-nats, singletons, template-haskell, th-desugar
API changes (from Hackage documentation)
- Data.Eliminator: elimBool :: forall (p_aqvV :: (~>) Bool Type) (s_aqvW :: Bool). Sing s_aqvW -> (@@) p_aqvV False -> (@@) p_aqvV True -> (@@) p_aqvV s_aqvW
+ Data.Eliminator: elimBool :: forall (p_alri :: (~>) Bool Type) (s_alrj :: Bool). Sing s_alrj -> (@@) p_alri False -> (@@) p_alri True -> (@@) p_alri s_alrj
- Data.Eliminator: elimEither :: forall (a_apE1 :: Type) (b_apE2 :: Type) (p_aqw1 :: (~>) (Either a_apE1 b_apE2) Type) (s_aqw2 :: Either a_apE1 b_apE2). Sing s_aqw2 -> (forall (f0_aqw3 :: a_apE1). Sing f0_aqw3 -> (@@) p_aqw1 (Left f0_aqw3)) -> (forall (f0_aqw4 :: b_apE2). Sing f0_aqw4 -> (@@) p_aqw1 (Right f0_aqw4)) -> (@@) p_aqw1 s_aqw2
+ Data.Eliminator: elimEither :: forall (a_aiQ7 :: Type) (b_aiQ8 :: Type) (p_alru :: (~>) (Either a_aiQ7 b_aiQ8) Type) (s_alrv :: Either a_aiQ7 b_aiQ8). Sing s_alrv -> (forall (f0_alrw :: a_aiQ7). Sing f0_alrw -> (@@) p_alru (Left f0_alrw)) -> (forall (f0_alrx :: b_aiQ8). Sing f0_alrx -> (@@) p_alru (Right f0_alrx)) -> (@@) p_alru s_alrv
- Data.Eliminator: elimList :: forall (a_11 :: Type) (p_aqWq :: (~>) ([] a_11) Type) (s_aqWr :: [] a_11). Sing s_aqWr -> (@@) p_aqWq [] -> (forall (f0_aqWs :: a_11). Sing f0_aqWs -> forall (f1_aqWt :: [a_11]). Sing f1_aqWt -> (@@) p_aqWq f1_aqWt -> (@@) p_aqWq ((:) f0_aqWs f1_aqWt)) -> (@@) p_aqWq s_aqWr
+ Data.Eliminator: elimList :: forall (a_11 :: Type) (p_alD7 :: (~>) ([] a_11) Type) (s_alD8 :: [] a_11). Sing s_alD8 -> (@@) p_alD7 [] -> (forall (f0_alD9 :: a_11). Sing f0_alD9 -> forall (f1_alDa :: [a_11]). Sing f1_alDa -> (@@) p_alD7 f1_alDa -> (@@) p_alD7 ((:) f0_alD9 f1_alDa)) -> (@@) p_alD7 s_alD8
- Data.Eliminator: elimMaybe :: forall (a_11 :: Type) (p_aqwd :: (~>) (Maybe a_11) Type) (s_aqwe :: Maybe a_11). Sing s_aqwe -> (@@) p_aqwd Nothing -> (forall (f0_aqwf :: a_11). Sing f0_aqwf -> (@@) p_aqwd (Just f0_aqwf)) -> (@@) p_aqwd s_aqwe
+ Data.Eliminator: elimMaybe :: forall (a_11 :: Type) (p_alrI :: (~>) (Maybe a_11) Type) (s_alrJ :: Maybe a_11). Sing s_alrJ -> (@@) p_alrI Nothing -> (forall (f0_alrK :: a_11). Sing f0_alrK -> (@@) p_alrI (Just f0_alrK)) -> (@@) p_alrI s_alrJ
- Data.Eliminator: elimNat :: forall (p_aqwm :: (~>) Nat Type) (s_aqwn :: Nat). Sing s_aqwn -> (@@) p_aqwm Z -> (forall (f0_aqwo :: Nat). Sing f0_aqwo -> (@@) p_aqwm f0_aqwo -> (@@) p_aqwm (S f0_aqwo)) -> (@@) p_aqwm s_aqwn
+ Data.Eliminator: elimNat :: forall (p_alrT :: (~>) Nat Type) (s_alrU :: Nat). Sing s_alrU -> (@@) p_alrT Z -> (forall (f0_alrV :: Nat). Sing f0_alrV -> (@@) p_alrT f0_alrV -> (@@) p_alrT (S f0_alrV)) -> (@@) p_alrT s_alrU
- Data.Eliminator: elimNonEmpty :: forall (a_akqR :: Type) (p_aqwv :: (~>) (NonEmpty a_akqR) Type) (s_aqww :: NonEmpty a_akqR). Sing s_aqww -> (forall (f0_aqwx :: a_akqR). Sing f0_aqwx -> forall (f1_aqwy :: [a_akqR]). Sing f1_aqwy -> (@@) p_aqwv ((:|) f0_aqwx f1_aqwy)) -> (@@) p_aqwv s_aqww
+ Data.Eliminator: elimNonEmpty :: forall (a_ac6N :: Type) (p_als3 :: (~>) (NonEmpty a_ac6N) Type) (s_als4 :: NonEmpty a_ac6N). Sing s_als4 -> (forall (f0_als5 :: a_ac6N). Sing f0_als5 -> forall (f1_als6 :: [a_ac6N]). Sing f1_als6 -> (@@) p_als3 ((:|) f0_als5 f1_als6)) -> (@@) p_als3 s_als4
- Data.Eliminator: elimOrdering :: forall (p_aqwE :: (~>) Ordering Type) (s_aqwF :: Ordering). Sing s_aqwF -> (@@) p_aqwE LT -> (@@) p_aqwE EQ -> (@@) p_aqwE GT -> (@@) p_aqwE s_aqwF
+ Data.Eliminator: elimOrdering :: forall (p_alsf :: (~>) Ordering Type) (s_alsg :: Ordering). Sing s_alsg -> (@@) p_alsf LT -> (@@) p_alsf EQ -> (@@) p_alsf GT -> (@@) p_alsf s_alsg
- Data.Eliminator: elimTuple0 :: forall (p_ar3E :: (~>) () Type) (s_ar3F :: ()). Sing s_ar3F -> (@@) p_ar3E () -> (@@) p_ar3E s_ar3F
+ Data.Eliminator: elimTuple0 :: forall (p_alH8 :: (~>) () Type) (s_alH9 :: ()). Sing s_alH9 -> (@@) p_alH8 () -> (@@) p_alH8 s_alH9
- Data.Eliminator: elimTuple2 :: forall (a_11 :: Type) (b_12 :: Type) (p_ar3H :: (~>) ((,) a_11 b_12) Type) (s_ar3I :: (,) a_11 b_12). Sing s_ar3I -> (forall (f0_ar3J :: a_11). Sing f0_ar3J -> forall (f1_ar3K :: b_12). Sing f1_ar3K -> (@@) p_ar3H ((,) f0_ar3J f1_ar3K)) -> (@@) p_ar3H s_ar3I
+ Data.Eliminator: elimTuple2 :: forall (a_11 :: Type) (b_12 :: Type) (p_alHd :: (~>) ((,) a_11 b_12) Type) (s_alHe :: (,) a_11 b_12). Sing s_alHe -> (forall (f0_alHf :: a_11). Sing f0_alHf -> forall (f1_alHg :: b_12). Sing f1_alHg -> (@@) p_alHd ((,) f0_alHf f1_alHg)) -> (@@) p_alHd s_alHe
- Data.Eliminator: elimTuple3 :: forall (a_11 :: Type) (b_12 :: Type) (c_13 :: Type) (p_ar3Q :: (~>) ((,,) a_11 b_12 c_13) Type) (s_ar3R :: (,,) a_11 b_12 c_13). Sing s_ar3R -> (forall (f0_ar3S :: a_11). Sing f0_ar3S -> forall (f1_ar3T :: b_12). Sing f1_ar3T -> forall (f2_ar3U :: c_13). Sing f2_ar3U -> (@@) p_ar3Q ((,,) f0_ar3S f1_ar3T f2_ar3U)) -> (@@) p_ar3Q s_ar3R
+ Data.Eliminator: elimTuple3 :: forall (a_11 :: Type) (b_12 :: Type) (c_13 :: Type) (p_alHp :: (~>) ((,,) a_11 b_12 c_13) Type) (s_alHq :: (,,) a_11 b_12 c_13). Sing s_alHq -> (forall (f0_alHr :: a_11). Sing f0_alHr -> forall (f1_alHs :: b_12). Sing f1_alHs -> forall (f2_alHt :: c_13). Sing f2_alHt -> (@@) p_alHp ((,,) f0_alHr f1_alHs f2_alHt)) -> (@@) p_alHp s_alHq
- Data.Eliminator: elimTuple4 :: forall (a_11 :: Type) (b_12 :: Type) (c_13 :: Type) (d_14 :: Type) (p_ar42 :: (~>) ((,,,) a_11 b_12 c_13 d_14) Type) (s_ar43 :: (,,,) a_11 b_12 c_13 d_14). Sing s_ar43 -> (forall (f0_ar44 :: a_11). Sing f0_ar44 -> forall (f1_ar45 :: b_12). Sing f1_ar45 -> forall (f2_ar46 :: c_13). Sing f2_ar46 -> forall (f3_ar47 :: d_14). Sing f3_ar47 -> (@@) p_ar42 ((,,,) f0_ar44 f1_ar45 f2_ar46 f3_ar47)) -> (@@) p_ar42 s_ar43
+ Data.Eliminator: elimTuple4 :: forall (a_11 :: Type) (b_12 :: Type) (c_13 :: Type) (d_14 :: Type) (p_alHF :: (~>) ((,,,) a_11 b_12 c_13 d_14) Type) (s_alHG :: (,,,) a_11 b_12 c_13 d_14). Sing s_alHG -> (forall (f0_alHH :: a_11). Sing f0_alHH -> forall (f1_alHI :: b_12). Sing f1_alHI -> forall (f2_alHJ :: c_13). Sing f2_alHJ -> forall (f3_alHK :: d_14). Sing f3_alHK -> (@@) p_alHF ((,,,) f0_alHH f1_alHI f2_alHJ f3_alHK)) -> (@@) p_alHF s_alHG
- Data.Eliminator: elimTuple5 :: forall (a_11 :: Type) (b_12 :: Type) (c_13 :: Type) (d_14 :: Type) (e_15 :: Type) (p_ar4h :: (~>) ((,,,,) a_11 b_12 c_13 d_14 e_15) Type) (s_ar4i :: (,,,,) a_11 b_12 c_13 d_14 e_15). Sing s_ar4i -> (forall (f0_ar4j :: a_11). Sing f0_ar4j -> forall (f1_ar4k :: b_12). Sing f1_ar4k -> forall (f2_ar4l :: c_13). Sing f2_ar4l -> forall (f3_ar4m :: d_14). Sing f3_ar4m -> forall (f4_ar4n :: e_15). Sing f4_ar4n -> (@@) p_ar4h ((,,,,) f0_ar4j f1_ar4k f2_ar4l f3_ar4m f4_ar4n)) -> (@@) p_ar4h s_ar4i
+ Data.Eliminator: elimTuple5 :: forall (a_11 :: Type) (b_12 :: Type) (c_13 :: Type) (d_14 :: Type) (e_15 :: Type) (p_alHZ :: (~>) ((,,,,) a_11 b_12 c_13 d_14 e_15) Type) (s_alI0 :: (,,,,) a_11 b_12 c_13 d_14 e_15). Sing s_alI0 -> (forall (f0_alI1 :: a_11). Sing f0_alI1 -> forall (f1_alI2 :: b_12). Sing f1_alI2 -> forall (f2_alI3 :: c_13). Sing f2_alI3 -> forall (f3_alI4 :: d_14). Sing f3_alI4 -> forall (f4_alI5 :: e_15). Sing f4_alI5 -> (@@) p_alHZ ((,,,,) f0_alI1 f1_alI2 f2_alI3 f3_alI4 f4_alI5)) -> (@@) p_alHZ s_alI0
- Data.Eliminator: elimTuple6 :: forall (a_11 :: Type) (b_12 :: Type) (c_13 :: Type) (d_14 :: Type) (e_15 :: Type) (f_16 :: Type) (p_ar4z :: (~>) ((,,,,,) a_11 b_12 c_13 d_14 e_15 f_16) Type) (s_ar4A :: (,,,,,) a_11 b_12 c_13 d_14 e_15 f_16). Sing s_ar4A -> (forall (f0_ar4B :: a_11). Sing f0_ar4B -> forall (f1_ar4C :: b_12). Sing f1_ar4C -> forall (f2_ar4D :: c_13). Sing f2_ar4D -> forall (f3_ar4E :: d_14). Sing f3_ar4E -> forall (f4_ar4F :: e_15). Sing f4_ar4F -> forall (f5_ar4G :: f_16). Sing f5_ar4G -> (@@) p_ar4z ((,,,,,) f0_ar4B f1_ar4C f2_ar4D f3_ar4E f4_ar4F f5_ar4G)) -> (@@) p_ar4z s_ar4A
+ Data.Eliminator: elimTuple6 :: forall (a_11 :: Type) (b_12 :: Type) (c_13 :: Type) (d_14 :: Type) (e_15 :: Type) (f_16 :: Type) (p_alIn :: (~>) ((,,,,,) a_11 b_12 c_13 d_14 e_15 f_16) Type) (s_alIo :: (,,,,,) a_11 b_12 c_13 d_14 e_15 f_16). Sing s_alIo -> (forall (f0_alIp :: a_11). Sing f0_alIp -> forall (f1_alIq :: b_12). Sing f1_alIq -> forall (f2_alIr :: c_13). Sing f2_alIr -> forall (f3_alIs :: d_14). Sing f3_alIs -> forall (f4_alIt :: e_15). Sing f4_alIt -> forall (f5_alIu :: f_16). Sing f5_alIu -> (@@) p_alIn ((,,,,,) f0_alIp f1_alIq f2_alIr f3_alIs f4_alIt f5_alIu)) -> (@@) p_alIn s_alIo
- Data.Eliminator: elimTuple7 :: forall (a_11 :: Type) (b_12 :: Type) (c_13 :: Type) (d_14 :: Type) (e_15 :: Type) (f_16 :: Type) (g_17 :: Type) (p_ar4U :: (~>) ((,,,,,,) a_11 b_12 c_13 d_14 e_15 f_16 g_17) Type) (s_ar4V :: (,,,,,,) a_11 b_12 c_13 d_14 e_15 f_16 g_17). Sing s_ar4V -> (forall (f0_ar4W :: a_11). Sing f0_ar4W -> forall (f1_ar4X :: b_12). Sing f1_ar4X -> forall (f2_ar4Y :: c_13). Sing f2_ar4Y -> forall (f3_ar4Z :: d_14). Sing f3_ar4Z -> forall (f4_ar50 :: e_15). Sing f4_ar50 -> forall (f5_ar51 :: f_16). Sing f5_ar51 -> forall (f6_ar52 :: g_17). Sing f6_ar52 -> (@@) p_ar4U ((,,,,,,) f0_ar4W f1_ar4X f2_ar4Y f3_ar4Z f4_ar50 f5_ar51 f6_ar52)) -> (@@) p_ar4U s_ar4V
+ Data.Eliminator: elimTuple7 :: forall (a_11 :: Type) (b_12 :: Type) (c_13 :: Type) (d_14 :: Type) (e_15 :: Type) (f_16 :: Type) (g_17 :: Type) (p_alIP :: (~>) ((,,,,,,) a_11 b_12 c_13 d_14 e_15 f_16 g_17) Type) (s_alIQ :: (,,,,,,) a_11 b_12 c_13 d_14 e_15 f_16 g_17). Sing s_alIQ -> (forall (f0_alIR :: a_11). Sing f0_alIR -> forall (f1_alIS :: b_12). Sing f1_alIS -> forall (f2_alIT :: c_13). Sing f2_alIT -> forall (f3_alIU :: d_14). Sing f3_alIU -> forall (f4_alIV :: e_15). Sing f4_alIV -> forall (f5_alIW :: f_16). Sing f5_alIW -> forall (f6_alIX :: g_17). Sing f6_alIX -> (@@) p_alIP ((,,,,,,) f0_alIR f1_alIS f2_alIT f3_alIU f4_alIV f5_alIW f6_alIX)) -> (@@) p_alIP s_alIQ
Files
- CHANGELOG.md +3/−0
- eliminators.cabal +9/−8
- src/Data/Eliminator/TH.hs +10/−6
- tests/DecideSpec.hs +3/−4
- tests/DecideTypes.hs +2/−8
- tests/ListSpec.hs +3/−3
- tests/ListTypes.hs +1/−1
- tests/VecSpec.hs +4/−4
- tests/VecTypes.hs +3/−3
CHANGELOG.md view
@@ -1,3 +1,6 @@+## 0.4 [2018.01.09]+* Require `singletons-2.4` and GHC 8.4.+ ## 0.3 [2017-11-07] * Migrate the old `elimNat` from `Data.Eliminator` (which worked over the `Nat` from `GHC.TypeNats`) to `Data.Eliminator.TypeNats`. There `elimNat` that now
eliminators.cabal view
@@ -1,5 +1,5 @@ name: eliminators-version: 0.3+version: 0.4 synopsis: Dependently typed elimination functions using singletons description: This library provides eliminators for inductive data types, leveraging the power of the @singletons@ library to allow@@ -16,7 +16,7 @@ build-type: Simple extra-source-files: CHANGELOG.md, README.md cabal-version: >=1.10-tested-with: GHC == 8.2.1+tested-with: GHC == 8.4.1 source-repository head type: git@@ -26,13 +26,13 @@ exposed-modules: Data.Eliminator Data.Eliminator.TH Data.Eliminator.TypeNats- build-depends: base >= 4.10 && < 4.11+ build-depends: base >= 4.11 && < 4.12 , extra >= 1.4.2 && < 1.7- , singletons >= 2.3 && < 2.4+ , singletons >= 2.4 && < 2.5 , singleton-nats >= 0.4.0.3 && < 0.5- , template-haskell >= 2.12 && < 2.13+ , template-haskell >= 2.13 && < 2.14 , th-abstraction >= 0.2.3 && < 0.3- , th-desugar >= 1.7 && < 1.8+ , th-desugar >= 1.8 && < 1.9 hs-source-dirs: src default-language: Haskell2010 ghc-options: -Wall -Wno-unticked-promoted-constructors@@ -48,11 +48,12 @@ ListTypes VecTypes VecSpec- build-depends: base >= 4.10 && < 4.11+ build-depends: base >= 4.11 && < 4.12 , eliminators , hspec >= 2 && < 3- , singletons >= 2.3 && < 2.4+ , singletons >= 2.4 && < 2.5 , singleton-nats >= 0.4.0.3 && < 0.5+ build-tool-depends: hspec-discover:hspec-discover hs-source-dirs: tests default-language: Haskell2010 ghc-options: -Wall -Wno-unticked-promoted-constructors -threaded -rtsopts
src/Data/Eliminator/TH.hs view
@@ -346,14 +346,18 @@ | nm == '(:) = 'SCons | Just degree <- tupleNameDegree_maybe nm = mkTupleDataName degree | Just degree <- unboxedTupleNameDegree_maybe nm = mkTupleDataName degree- | otherwise = prefixUCName "S" ":%" nm+ | otherwise = prefixConName "S" "%" nm mkTupleDataName :: Int -> Name mkTupleDataName n = mkName $ "STuple" ++ (show n) --- put an uppercase prefix on a name. Takes two prefixes: one for identifiers--- and one for symbols-prefixUCName :: String -> String -> Name -> Name-prefixUCName pre tyPre n = case (nameBase n) of- (':' : rest) -> mkName (tyPre ++ rest)+-- Put an uppercase prefix on a constructor name. Takes two prefixes:+-- one for identifiers and one for symbols.+--+-- This is different from 'prefixName' in that infix constructor names always+-- start with a colon, so we must insert the prefix after the colon in order+-- for the new name to be syntactically valid.+prefixConName :: String -> String -> Name -> Name+prefixConName pre tyPre n = case (nameBase n) of+ (':' : rest) -> mkName (':' : tyPre ++ rest) alpha -> mkName (pre ++ alpha)
tests/DecideSpec.hs view
@@ -39,8 +39,7 @@ show (decEqNatList (SCons (sLit @0) SNil) SNil) `shouldBe` disproved show (decEqNatList SNil (SCons (sLit @0) SNil)) `shouldBe` disproved show (decEqNatList (SCons (sLit @0) SNil) (SCons (sLit @0) SNil)) `shouldBe` proved- -- TODO: Try this in the next version of singletons- -- show (decEqNatList (SCons (sLit @1) SNil) (SCons (sLit @0) SNil)) `shouldBe` disproved+ show (decEqNatList (SCons (sLit @1) SNil) (SCons (sLit @0) SNil)) `shouldBe` disproved ----- @@ -86,14 +85,14 @@ where left :: forall (x :: n :~: j). Sing x -> Decision (S n :~: S j)- left yes = Proved $ cong @Nat @Nat @(TyCon1 S) @n @j (fromSing yes)+ left yes = Proved $ cong @Nat @Nat @(TyCon S) @n @j (fromSing yes) right :: forall (r :: (n :~: j) ~> Void). Sing r -> Decision (S n :~: S j) right no = Disproved $ fromSing no . sInjective @n @j sn decEqNat :: forall (n :: Nat) (j :: Nat). Sing n -> Sing j -> Decision (n :~: j)-decEqNat sn = runWhyDecEqNat (elimNat @(TyCon1 WhyDecEqNat) @n sn base step)+decEqNat sn = runWhyDecEqNat (elimNat @(TyCon WhyDecEqNat) @n sn base step) where base :: WhyDecEqNat Z base = WhyDecEqNat decEqZ
tests/DecideTypes.hs view
@@ -9,18 +9,12 @@ {-# LANGUAGE TypeInType #-} {-# LANGUAGE TypeOperators #-} {-# LANGUAGE UndecidableInstances #-}--- TODO: Remove this in the next version of singletons-{-# OPTIONS_GHC -Wno-orphans #-} module DecideTypes where import Data.Kind import Data.Nat import Data.Singletons.TH hiding (Decision(..)) --- TODO: Remove these in the next version of singletons-$(genSingletons [''Void])-$(genDefunSymbols [''(~>)])- -- Due to https://github.com/goldfirere/singletons/issues/82, promoting the -- Decision data type from Data.Singletons.Decide is a tad awkward. To work -- around these, we define a more general Decision' data type here.@@ -42,8 +36,8 @@ showsPrec p (Disproved _) = showParen (p > 10) $ showString "Disproved <void>" -type Decision = Decision' (TyCon2 (->))-type PDecision = Decision' (:~>$)+type Decision = Decision' (TyCon (->))+type PDecision = Decision' (~>@#@$) data instance Sing (z :: PDecision a) where -- It would be lovely to not have to write those (:: PDecision a) kind
tests/ListSpec.hs view
@@ -41,12 +41,12 @@ Sing s -> Sing ss -> WhyMapPreservesLength f ss -> WhyMapPreservesLength f (s:ss)- step _ _ = cong @_ @_ @((:+$$) 1)+ step _ _ = cong @_ @_ @((+@#@$$) 1) mapFusion :: forall (x :: Type) (y :: Type) (z :: Type) (f :: y ~> z) (g :: x ~> y) (l :: [x]). SingI l- => Map f (Map g l) :~: Map (f :.$$$ g) l+ => Map f (Map g l) :~: Map (f .@#@$$$ g) l mapFusion = elimList @x @(WhyMapFusionSym2 f g) @l (sing @_ @l) base step where@@ -57,4 +57,4 @@ Sing s -> Sing ss -> WhyMapFusion f g ss -> WhyMapFusion f g (s:ss)- step _ _ = cong @_ @_ @((:$$) (f @@ (g @@ s)))+ step _ _ = cong @_ @_ @((:@#@$$) (f @@ (g @@ s)))
tests/ListTypes.hs view
@@ -15,5 +15,5 @@ $(genDefunSymbols [''WhyMapPreservesLength]) type WhyMapFusion (f :: y ~> z) (g :: x ~> y) (l :: [x])- = Map f (Map g l) :~: Map (f :.$$$ g) l+ = Map f (Map g l) :~: Map (f .@#@$$$ g) l $(genDefunSymbols [''WhyMapFusion])
tests/VecSpec.hs view
@@ -6,7 +6,7 @@ module VecSpec where import Data.Eliminator-import Data.Kind+import Data.Kind (Type) import Data.Nat import Data.Singletons import Data.Singletons.Prelude.Num@@ -69,7 +69,7 @@ replicateVec :: forall (e :: Type) (howMany :: Nat). Sing howMany -> e -> Vec e howMany-replicateVec s e = elimNat @(TyCon1 (Vec e)) @howMany s VNil step+replicateVec s e = elimNat @(TyCon (Vec e)) @howMany s VNil step where step :: forall (k :: Nat). Sing k -> Vec e k -> Vec e (S k) step _ = (e :#)@@ -102,7 +102,7 @@ appendVec :: forall (e :: Type) (n :: Nat) (m :: Nat). SingI n- => Vec e n -> Vec e m -> Vec e (n :+ m)+ => Vec e n -> Vec e m -> Vec e (n + m) appendVec = elimNat @(WhyAppendVecSym2 e m) @n (sing @_ @n) base step where base :: WhyAppendVec e m Z@@ -130,7 +130,7 @@ concatVec :: forall (e :: Type) (n :: Nat) (j :: Nat). (SingKind e, SingI j, e ~ Demote e)- => Vec (Vec e j) n -> Vec e (n :* j)+ => Vec (Vec e j) n -> Vec e (n * j) concatVec l = withSomeSing l $ \(singL :: Sing l) -> elimVec @(Vec e j) @n @(WhyConcatVecSym e j) @l singL base step where
tests/VecTypes.hs view
@@ -11,7 +11,7 @@ {-# LANGUAGE UndecidableInstances #-} module VecTypes where -import Data.Kind+import Data.Kind (Type) import Data.Nat import Data.Singletons.Prelude.Num import Data.Singletons.TH@@ -65,7 +65,7 @@ $(genDefunSymbols [''WhyZipWithVec]) type WhyAppendVec (e :: Type) (m :: Nat) (n :: Nat)- = Vec e n -> Vec e m -> Vec e (n :+ m)+ = Vec e n -> Vec e m -> Vec e (n + m) $(genDefunSymbols [''WhyAppendVec]) type WhyTransposeVec (e :: Type) (m :: Nat) (n :: Nat)@@ -73,7 +73,7 @@ $(genDefunSymbols [''WhyTransposeVec]) type WhyConcatVec (e :: Type) (j :: Nat) (n :: Nat) (l :: Vec (Vec e j) n)- = Vec e (n :* j)+ = Vec e (n * j) data WhyConcatVecSym (e :: Type) (j :: Nat) :: forall (n :: Nat). Vec (Vec e j) n ~> Type type instance Apply (WhyConcatVecSym e j :: Vec (Vec e j) n ~> Type) l