packages feed

type-fun 0.1.1 → 0.1.2

raw patch · 4 files changed

+19/−4 lines, 4 files

Files

CHANGELOG.md view
@@ -4,6 +4,9 @@  # CHANGELOG +## 0.1.2+### Added KnownPeano+ ## 0.1.1 ### Fixed * Compilable with ghc-8.0.1
example/Main.hs view
@@ -37,4 +37,5 @@   print $ prefixConstr p2   print $ prefixConstr p3   print $ uniqConstr p2+  print $ peanoVal (Proxy :: Proxy (FromNat 100))   -- print $ uniqConstr p3 -- < ElementIsNotUniqInList Int '[Int, Bool, Int]
src/TypeFun/Data/Peano.hs view
@@ -1,5 +1,6 @@ module TypeFun.Data.Peano   ( N(..)+  , KnownPeano(..)   , ToNat   , FromNat   , (:+:)@@ -7,13 +8,23 @@   , (:*:)   ) where -import Data.Typeable-import GHC.Generics (Generic)-import GHC.TypeLits+import           Data.Typeable+import           GHC.Generics  (Generic)+import           GHC.TypeLits  data N = Z | S N          deriving ( Eq, Ord, Read, Show                   , Generic, Typeable )++-- | @since 0.1.2+class KnownPeano (p :: N) where+  peanoVal :: proxy p -> Integer++instance KnownPeano Z where+  peanoVal _ = 0++instance (KnownPeano n) => KnownPeano (S n) where+  peanoVal _ = succ $ peanoVal (Proxy :: Proxy n)  type family ToNat (a :: N) :: Nat where   ToNat Z = 0
type-fun.cabal view
@@ -1,5 +1,5 @@ name:                type-fun-version:             0.1.1+version:             0.1.2 synopsis:            Collection of widely reimplemented type families license:             BSD3 license-file:        LICENSE