packages feed

acme-numbersystem 0.2.0.0 → 0.3.0.0

raw patch · 2 files changed

+8/−4 lines, 2 files

Files

Acme/NumberSystem.hs view
@@ -5,13 +5,14 @@ import Language.Haskell.TH  type Less = (<=)+type family Add (m :: Nat) (n :: Nat) :: Nat type family Sub (m :: Nat) (n :: Nat) :: Nat  -- | Define the less than relation for numbers up to a number using Template Haskell. -- | Also define subtraction. -- | E.g. numberSystem 100 numberSystem :: Integer -> Q [Dec]-numberSystem theBiggestNumber = return . concat $ lessThan ++ subs+numberSystem theBiggestNumber = return . concat $ lessThan ++ subs ++ [adds]   where     lessThan = map (\i -> map (\j ->       InstanceD [] (AppT (AppT (ConT (''Less)) (LitT (NumTyLit i))) (LitT (NumTyLit j))) []@@ -19,3 +20,6 @@     subs = map (\i -> map (\j ->       TySynInstD ''Sub [LitT (NumTyLit j), LitT (NumTyLit i)] (LitT (NumTyLit (j - i)))       ) [i..theBiggestNumber]) [0..theBiggestNumber]+    adds = map (\i ->+      TySynInstD ''Add [LitT (NumTyLit i), LitT (NumTyLit 1)] (LitT (NumTyLit (i + 1)))+      ) [0..theBiggestNumber]
acme-numbersystem.cabal view
@@ -1,7 +1,7 @@ name:                acme-numbersystem-version:             0.2.0.0-synopsis:            Define the less than and subtraction for nats-description:         Define the less than relation and subtraction for numbers up to a number by using Template Haskell.+version:             0.3.0.0+synopsis:            Define the less than and add and subtract for nats+description:         Define the less than relation, add and subtract for numbers up to a number by using Template Haskell. license:             BSD3 license-file:        LICENSE author:              Maxwell Swadling