packages feed

type-combinators 0.1.2.0 → 0.1.2.1

raw patch · 2 files changed

+16/−2 lines, 2 files

Files

src/Data/Type/Index/Quote.hs view
@@ -27,7 +27,7 @@ ix :: QuasiQuoter ix = QuasiQuoter   { quoteExp  = parseIxExp-  , quotePat  = error "ix: quotePat not defined"+  , quotePat  = parseIxPat   , quoteType = error "ix: quoteType not defined"   , quoteDec  = error "ix: quoteDec not defined"   }@@ -45,4 +45,18 @@   go = \case     0 -> [| IZ |]     n -> [| IS $(go $ n-1) |]++parseIxPat :: String -> Q Pat+parseIxPat s = maybe (fail $ "ix: couldn't parse Int: " ++ show s)+  (notNeg >=> go)+  $ readMaybe s+  where+  notNeg :: Int -> Q Int+  notNeg n+    | n < 0 = fail $ "ix: negative index: " ++ show n+    | True  = return n+  go :: Int -> Q Pat+  go = \case+    0 -> [p| IZ |]+    n -> [p| IS $(go $ n-1) |] 
type-combinators.cabal view
@@ -1,5 +1,5 @@ name: type-combinators-version: 0.1.2.0+version: 0.1.2.1 category: Data synopsis: A collection of data types for type-level programming cabal-version: >=1.10