packages feed

type-iso 0.1.0.0 → 1.0.0.0

raw patch · 4 files changed

+14/−18 lines, 4 filesnew-uploaderPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

- Data.Types.Injective: instance Default a => Injective (Maybe b) (Either a b)
- Data.Types.Injective: instance Injective Integer Rational
- Data.Types.Injective: instance Injective Integer Whole
- Data.Types.Injective: instance Injective Nat Integer
- Data.Types.Injective: instance Injective Nat Natural
- Data.Types.Injective: instance Injective Nat Rational
- Data.Types.Injective: instance Injective Nat Whole
- Data.Types.Injective: instance Injective Natural Integer
- Data.Types.Injective: instance Injective Natural Nat
- Data.Types.Injective: instance Injective Natural Rational
- Data.Types.Injective: instance Injective Natural Whole
- Data.Types.Injective: instance Injective String Text
- Data.Types.Injective: instance Injective Text String
- Data.Types.Injective: instance Injective Text Text
- Data.Types.Injective: instance Injective Whole Integer
- Data.Types.Injective: instance Injective Whole Rational
- Data.Types.Injective: instance Injective a a
- Data.Types.Isomorphic: instance Iso Integer Whole
- Data.Types.Isomorphic: instance Iso String Text
- Data.Types.Isomorphic: instance Iso Text String
- Data.Types.Isomorphic: instance Iso Text Text
- Data.Types.Isomorphic: instance Iso Whole Integer
- Data.Types.Isomorphic: instance Iso a a
+ Data.Types.Injective: instance Data.Default.Class.Default a => Data.Types.Injective.Injective (GHC.Base.Maybe b) (Data.Either.Either a b)
+ Data.Types.Injective: instance Data.Types.Injective.Injective Data.Text.Internal.Lazy.Text Data.Text.Internal.Text
+ Data.Types.Injective: instance Data.Types.Injective.Injective Data.Text.Internal.Lazy.Text GHC.Base.String
+ Data.Types.Injective: instance Data.Types.Injective.Injective Data.Text.Internal.Text Data.Text.Internal.Lazy.Text
+ Data.Types.Injective: instance Data.Types.Injective.Injective Data.Text.Internal.Text GHC.Base.String
+ Data.Types.Injective: instance Data.Types.Injective.Injective GHC.Base.String Data.Text.Internal.Lazy.Text
+ Data.Types.Injective: instance Data.Types.Injective.Injective GHC.Base.String Data.Text.Internal.Text
+ Data.Types.Injective: instance Data.Types.Injective.Injective GHC.Integer.Type.Integer GHC.Real.Rational
+ Data.Types.Injective: instance Data.Types.Injective.Injective GHC.Integer.Type.Integer Numeric.Peano.Whole
+ Data.Types.Injective: instance Data.Types.Injective.Injective GHC.Natural.Natural GHC.Integer.Type.Integer
+ Data.Types.Injective: instance Data.Types.Injective.Injective GHC.Natural.Natural GHC.Real.Rational
+ Data.Types.Injective: instance Data.Types.Injective.Injective GHC.Natural.Natural Numeric.Peano.Nat
+ Data.Types.Injective: instance Data.Types.Injective.Injective GHC.Natural.Natural Numeric.Peano.Whole
+ Data.Types.Injective: instance Data.Types.Injective.Injective Numeric.Peano.Nat GHC.Integer.Type.Integer
+ Data.Types.Injective: instance Data.Types.Injective.Injective Numeric.Peano.Nat GHC.Natural.Natural
+ Data.Types.Injective: instance Data.Types.Injective.Injective Numeric.Peano.Nat GHC.Real.Rational
+ Data.Types.Injective: instance Data.Types.Injective.Injective Numeric.Peano.Nat Numeric.Peano.Whole
+ Data.Types.Injective: instance Data.Types.Injective.Injective Numeric.Peano.Whole GHC.Integer.Type.Integer
+ Data.Types.Injective: instance Data.Types.Injective.Injective Numeric.Peano.Whole GHC.Real.Rational
+ Data.Types.Injective: instance Data.Types.Injective.Injective a a
+ Data.Types.Isomorphic: instance Data.Types.Isomorphic.Iso Data.Text.Internal.Lazy.Text Data.Text.Internal.Text
+ Data.Types.Isomorphic: instance Data.Types.Isomorphic.Iso Data.Text.Internal.Lazy.Text GHC.Base.String
+ Data.Types.Isomorphic: instance Data.Types.Isomorphic.Iso Data.Text.Internal.Text Data.Text.Internal.Lazy.Text
+ Data.Types.Isomorphic: instance Data.Types.Isomorphic.Iso Data.Text.Internal.Text GHC.Base.String
+ Data.Types.Isomorphic: instance Data.Types.Isomorphic.Iso GHC.Base.String Data.Text.Internal.Lazy.Text
+ Data.Types.Isomorphic: instance Data.Types.Isomorphic.Iso GHC.Base.String Data.Text.Internal.Text
+ Data.Types.Isomorphic: instance Data.Types.Isomorphic.Iso GHC.Integer.Type.Integer Numeric.Peano.Whole
+ Data.Types.Isomorphic: instance Data.Types.Isomorphic.Iso Numeric.Peano.Whole GHC.Integer.Type.Integer
+ Data.Types.Isomorphic: instance Data.Types.Isomorphic.Iso a a
- Data.Types.Injective: to :: Injective a b => a -> b
+ Data.Types.Injective: to :: forall b1 a1. (Injective a b, b1 ~ b, a1 ~ a) => a -> b
- Data.Types.Isomorphic: from :: Iso a b => b -> a
+ Data.Types.Isomorphic: from :: forall b a. (Iso a b) => b -> a

Files

Data/Types/Injective.hs view
@@ -1,6 +1,9 @@ {-# LANGUAGE MultiParamTypeClasses #-}
 {-# LANGUAGE FlexibleContexts #-}
 {-# LANGUAGE FlexibleInstances #-}
+{-# LANGUAGE ExplicitForAll #-}
+{-# LANGUAGE ScopedTypeVariables #-}
+{-# LANGUAGE GADTs #-}
 
 -- |Injective types. This module contains the 'Injective' typeclass and instances
 --  for the following equivalence classes:
@@ -47,7 +50,7 @@ --  @to@ should be a total function. No cheating by it undefined for parts of the set!
 class Injective a b where
    -- |Converts a value of type @a@ "losslessly" to one of type @b@.
-   to :: a -> b
+   to :: forall b1 a1. (b1 ~ b, a1 ~ a) => a -> b
 
 instance Injective a a where
    to = id
Data/Types/Isomorphic.hs view
@@ -1,5 +1,6 @@ {-# LANGUAGE MultiParamTypeClasses #-}
 {-# LANGUAGE FlexibleInstances #-}
+{-# LANGUAGE ExplicitForAll #-}
 
 -- |Contains the class definition of 'Iso', indicating isomorphism between two
 --  types.
@@ -17,7 +18,7 @@ import Data.Types.Injective
 
 -- |The class of isomorphic types, i.e. those which can be cast to each
---  other withouth loss of information. Type isomorphism is an equivalence
+--  other without loss of information. Type isomorphism is an equivalence
 --  relation (reflexive, symmetric, transitive), but due to the limitations
 --  of the type system, only reflexivity is implemented for all types.
 --  Since there are no type inequality constraints, writing symmetry and
@@ -28,27 +29,17 @@ --
 --  [@Isomorphism@]
 -- @
--- isoFrom . isoTo = id
+-- from . to = id
 -- @
 --
 --  Reflexivity, symmetry and transitivity are then "free":
 --
 -- @
--- instance Iso a a where
---    isoTo = id
---    isoFrom = id
--- @
---
--- @
--- instance Iso a b => Iso b a where
---    isoTo = isoFrom
---    isoFrom = isoTo
+-- instance Iso a a
 -- @
 --
 -- @
--- instance (Iso a b, Iso b c) => Iso a c where
---   isoTo = isoTo . isoTo
---   isFrom = isoFrom . isoFrom
+-- instance (Iso a b, Iso b c) => Iso a c
 -- @
 --
 --  Out of these, only the first one (reflexivity) is actually implemented,
@@ -58,7 +49,7 @@ class (Injective a b, Injective b a) => Iso a b where
 
 -- |Synonym for 'to'.
-from :: (Iso a b) => b -> a
+from :: forall b a. (Iso a b) => b -> a
 from = to
 
 instance Iso a a where
+ changelog.txt view
@@ -0,0 +1,1 @@+1.0.0.0 Renamed 'isoFrom' and 'isoTo' to just 'from' and 'to', flipped the type argument order to allow specifying the target type first.
type-iso.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/
 
 name:                type-iso
-version:             0.1.0.0
+version:             1.0.0.0
 synopsis:            Typeclasses for injective relations and isomorphisms between types.
 description:         This package defines \"can be cast to\" relations between types: two types a and b are an instance of Injective if there's an injective function from a to b. If there is also an injective function from b to a, a and b are instances of Iso, meaning that one can convert back and forth losslessly (up to some appropriate notion of equality). The main purpose of this little package is to provide easy casting between the common string types (String, strict/lazy Text) and numeric types (Integers, Peano numbers), without having to look up the names of the various conversion functions all the time.
 homepage:            https://github.com/ombocomp/type-iso
@@ -13,6 +13,7 @@ category:            Data, Cast, Types
 build-type:          Simple
 cabal-version:       >=1.10
+extra-source-files:  changelog.txt
 
 source-repository head
   type:     git
@@ -20,6 +21,6 @@ 
 library
   exposed-modules:     Data.Types.Isomorphic, Data.Types.Injective
-  other-extensions:    MultiParamTypeClasses, FlexibleInstances, FlexibleContexts
+  other-extensions:    MultiParamTypeClasses, FlexibleInstances, FlexibleContexts, ExplicitForAll, GADTs
   build-depends:       base >=4.7 && <5, nats >=0.2, text >=1.1, numericpeano >= 0.2, data-default >= 0.5
   default-language:    Haskell2010