packages feed

prim-uniq 0.1.0.1 → 0.2

raw patch · 7 files changed

+61/−18 lines, 7 filesdep ~dependent-sumnew-uploaderPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: dependent-sum

API changes (from Hackage documentation)

- Data.Unique.Tag: GEQ :: GOrdering t t
- Data.Unique.Tag: GGT :: GOrdering a b
- Data.Unique.Tag: GLT :: GOrdering a b
- Data.Unique.Tag: Refl :: := a a
- Data.Unique.Tag: data (:=) a b :: * -> * -> *
- Data.Unique.Tag: data GOrdering a b :: * -> * -> *
- Unsafe.Unique.Prim: instance Eq (Uniq s)
- Unsafe.Unique.Prim: instance Ord (Uniq s)
- Unsafe.Unique.Prim: instance Show (Uniq RealWorld)
- Unsafe.Unique.Tag: instance Eq (Tag s a)
- Unsafe.Unique.Tag: instance GCompare (Tag s)
- Unsafe.Unique.Tag: instance GEq (Tag s)
- Unsafe.Unique.Tag: instance GShow (Tag RealWorld)
- Unsafe.Unique.Tag: instance Ord (Tag s a)
- Unsafe.Unique.Tag: instance Show (Tag RealWorld a)
+ Data.Unique.Tag: [GEQ] :: forall k (a :: k) (b :: k). () => GOrdering a a
+ Data.Unique.Tag: [GGT] :: forall k (a :: k) (b :: k). () => GOrdering a b
+ Data.Unique.Tag: [GLT] :: forall k (a :: k) (b :: k). () => GOrdering a b
+ Data.Unique.Tag: [Refl] :: forall k (a :: k) (b :: k). () => a :~: a
+ Data.Unique.Tag: data GOrdering (a :: k) (b :: k) :: forall k. () => k -> k -> Type
+ Data.Unique.Tag: infix 4 :~:
+ Unsafe.Unique.Prim: instance GHC.Classes.Eq (Unsafe.Unique.Prim.Uniq s)
+ Unsafe.Unique.Prim: instance GHC.Classes.Ord (Unsafe.Unique.Prim.Uniq s)
+ Unsafe.Unique.Prim: instance GHC.Show.Show (Unsafe.Unique.Prim.Uniq GHC.Prim.RealWorld)
+ Unsafe.Unique.Tag: instance Data.GADT.Internal.GCompare (Unsafe.Unique.Tag.Tag s)
+ Unsafe.Unique.Tag: instance Data.GADT.Internal.GEq (Unsafe.Unique.Tag.Tag s)
+ Unsafe.Unique.Tag: instance Data.GADT.Internal.GShow (Unsafe.Unique.Tag.Tag GHC.Prim.RealWorld)
+ Unsafe.Unique.Tag: instance GHC.Classes.Eq (Unsafe.Unique.Tag.Tag s a)
+ Unsafe.Unique.Tag: instance GHC.Classes.Ord (Unsafe.Unique.Tag.Tag s a)
+ Unsafe.Unique.Tag: instance GHC.Show.Show (Unsafe.Unique.Tag.Tag GHC.Prim.RealWorld a)
- Data.Unique.Prim: data RealWorld :: *
+ Data.Unique.Prim: data RealWorld :: Type
- Data.Unique.Tag: class GEq f => GCompare f :: (* -> *)
+ Data.Unique.Tag: class GEq f => GCompare (f :: k -> Type)
- Data.Unique.Tag: class GEq f :: (* -> *)
+ Data.Unique.Tag: class GEq (f :: k -> Type)
- Data.Unique.Tag: data RealWorld :: *
+ Data.Unique.Tag: data RealWorld :: Type
- Data.Unique.Tag: geq :: GEq f => f a -> f b -> Maybe (:= a b)
+ Data.Unique.Tag: geq :: GEq f => f a -> f b -> Maybe (a :~: b)

Files

+ ChangeLog.md view
@@ -0,0 +1,7 @@+# Revision history for prim-uniq++## 0.2 - 2020-04-11++* Update for dependent-sum 0.7. (Support GHC 8.8.)+* `dependent-sum` dropped the `(:=)` type. Use `(:~:)` instead.+* Fix a minor strictness issue (#1).
+ README.md view
@@ -0,0 +1,34 @@+[![Build Status](https://travis-ci.org/github/obsidiansystems/prim-uniq.svg)](https://travis-ci.org/obsidiansystems/prim-uniq)++Unique values and an ad-hoc "unique-tag GADT"+=============================================++This library defines 2 types - `Uniq` and `Tag`.++`Uniq` is a traditional "unique value" type, extended with a state-token type parameter so it works in both `IO` and `ST`.++`Tag` is like `Uniq` with the addition of a phantom type parameter.  The type of that parameter is fixed at the time the `Tag` is created, so the uniqueness of the tag means that equality of tag values witnesses equality of their phantom types.  In other words, given two `Tag`s, if they are equal then their phantom type parameters are the same - just like pattern matching on a GADT constructor.  The `GEq` and `GCompare` classes from the `dependent-sum` package can be used to discover that type equality, allowing `Tag` to be used for a pretty cool semi-dynamic typing scheme.  For example (using the `dependent-map` library):++    import Data.Unique.Tag+    import Data.Dependent.Map+    +    main = do+        x <- newTag+        y <- newTag+        z <- newTag+        let m1 = fromList [x :=> 3,  y :=> "hello"]+            m2 = fromList [x :=> 17, z :=> (True, x)]+            -- the type checker would (rightly) reject this line:+            -- m3 = singleton y ("foo", "bar")+        +        print (m1 ! x)+        print (m1 ! y)+        print (m2 ! x)+        print (m1 ! snd (m2 ! z))++Which would print:++    3+    "hello"+    17+    3
prim-uniq.cabal view
@@ -1,29 +1,33 @@ name:                   prim-uniq-version:                0.1.0.1+version:                0.2 stability:              provisional  cabal-version:          >= 1.6 build-type:             Simple  author:                 James Cook <mokus@deepbondi.net>-maintainer:             James Cook <mokus@deepbondi.net>+maintainer:             Obsidian Systems, LLC <maintainer@obsidian.systems> license:                PublicDomain-homepage:               https://github.com/mokus0/prim-uniq+homepage:               https://github.com/obsidiansystems/prim-uniq  category:               Data, Dependent Types synopsis:               Opaque unique identifiers in primitive state monads-description:            Opaque unique identifiers in primitive state monads +description:            Opaque unique identifiers in primitive state monads                         and a GADT-like type using them as witnesses of type                         equality. -tested-with:            GHC == 7.2.1,-                        GHC == 7.0.4,-                        GHC == 6.12.3,-                        GHC == 6.10.4+extra-source-files:     README.md+                        ChangeLog.md +tested-with:            GHC == 8.0.2,+                        GHC == 8.2.2,+                        GHC == 8.4.3,+                        GHC == 8.6.3,+                        GHC == 8.8.3+ source-repository head   type:     git-  location: git://github.com/mokus0/prim-uniq.git+  location: https://github.com/obsidiansystems/prim-uniq  Library   hs-source-dirs:       src@@ -31,4 +35,6 @@                         Data.Unique.Tag                         Unsafe.Unique.Prim                         Unsafe.Unique.Tag-  build-depends:        base >= 3 && <5, dependent-sum, primitive+  build-depends:        base >= 3 && <5,+                        dependent-sum >= 0.7 && < 0.8,+                        primitive
src/Data/Unique/Prim.hs view
@@ -1,7 +1,4 @@-{-# LANGUAGE CPP #-}-#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 702 {-# LANGUAGE Trustworthy #-}-#endif module Data.Unique.Prim     ( Uniq, getUniq, RealWorld     ) where
src/Data/Unique/Tag.hs view
@@ -1,14 +1,11 @@-{-# LANGUAGE CPP #-}-#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 702 {-# LANGUAGE Trustworthy #-}-#endif module Data.Unique.Tag     ( Tag     , newTag          , RealWorld     -    , (:=)(..)+    , (:~:)(..)     , GEq(..)          , GOrdering(..)@@ -17,4 +14,5 @@  import Data.GADT.Compare import Unsafe.Unique.Tag+import Data.Type.Equality ((:~:)(..)) import Control.Monad.Primitive (RealWorld)
src/Unsafe/Unique/Prim.hs view
@@ -46,7 +46,7 @@ -- 'Uniq' constructed in the same monad, and incomparable to every 'Uniq'  -- constructed in any other monad. getUniq :: PrimMonad m => m (Uniq (PrimState m))-getUniq = unsafePrimToPrim (atomicModifyIORef nextUniq (\(!u) -> let !u' = u+1 in (u', Uniq u)))+getUniq = unsafePrimToPrim (atomicModifyIORef' nextUniq (\u -> (u+1, Uniq u)))  -- |For the implementation of 'Uniq' construction in new monads, this operation -- is exposed.  Users must accept responsibility for ensuring true uniqueness 
src/Unsafe/Unique/Tag.hs view
@@ -11,6 +11,7 @@ import Unsafe.Coerce import Control.Monad.Primitive import Control.Monad+import Data.Type.Equality ((:~:)(..))  -- |The 'Tag' type is like an ad-hoc GADT allowing runtime creation of new  -- constructors.  Specifically, it is like a GADT \"enumeration\" with one