pointless-haskell 0.0.7 → 0.0.8
raw patch · 2 files changed
+13/−11 lines, 2 filesdep −haskell98
Dependencies removed: haskell98
Files
pointless-haskell.cabal view
@@ -1,5 +1,5 @@ Name: pointless-haskell-Version: 0.0.7+Version: 0.0.8 License: BSD3 License-file: LICENSE Author: Alcino Cunha <alcino@di.uminho.pt>, Hugo Pacheco <hpacheco@di.uminho.pt>@@ -23,7 +23,7 @@ Library Hs-Source-Dirs: src- Build-Depends: base >= 3 && < 5, GHood, haskell98, process, syb >= 0.1.0.2+ Build-Depends: base >= 3 && < 5, GHood, process, syb >= 0.1.0.2 exposed-modules: Generics.Pointless.Combinators Generics.Pointless.Functors,
src/Generics/Pointless/Functors.hs view
@@ -316,16 +316,20 @@ -- ** Natural Numbers -data Nat = Zero | Succ Nat deriving (Eq,Show,Read,G.Typeable,G.Data)+-- Implemented as "boxed" integers for efficiency+data Nat = Nat Int deriving (Eq,Show,Read,G.Typeable,G.Data) type instance PF Nat = Const One :+: Id instance Mu Nat where- inn (Left _) = Zero- inn (Right n) = Succ n- out Zero = Left _L- out (Succ n) = Right n+ inn (Left _) = Nat 0+ inn (Right (Nat n)) = Nat (succ n)+ out (Nat 0) = Left _L+ out (Nat n) = if n < 1 then error "negative natural not expected" else Right (Nat $ pred n) +nzero = Nat 0+nsucc (Nat n) = Nat (succ n)+ -- ** Int (positive only) type instance PF Int = Const One :+: Id@@ -343,12 +347,10 @@ suck = inn . inr natInt :: Nat -> Int-natInt Zero = 0-natInt (Succ n) = succ (natInt n)+natInt (Nat n) = n intNat :: Int -> Nat-intNat 0 = Zero-intNat n = Succ (intNat $ pred n)+intNat n = if n < 0 then error "negative natural not expected" else Nat n -- ** Bool