packages feed

dependent-map 0.3.1.0 → 0.4.0.0

raw patch · 4 files changed

+44/−26 lines, 4 filesdep ~constraints-extrasdep ~containersPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: constraints-extras, containers

API changes (from Hackage documentation)

- Data.Dependent.Map: (:=>) :: !tag a -> f a -> DSum (tag :: k -> Type) (f :: k -> Type)
- Data.Dependent.Map: [GEQ] :: forall k (a :: k). GOrdering a a
- Data.Dependent.Map: [GGT] :: forall k (a :: k) (b :: k). GOrdering a b
- Data.Dependent.Map: [GLT] :: forall k (a :: k) (b :: k). GOrdering a b
- Data.Dependent.Map: class GEq f => GCompare (f :: k -> Type)
- Data.Dependent.Map: data DSum (tag :: k -> Type) (f :: k -> Type)
- Data.Dependent.Map: data GOrdering (a :: k) (b :: k)
- Data.Dependent.Map: data Some (tag :: k -> Type)
- Data.Dependent.Map: gcompare :: forall (a :: k) (b :: k). GCompare f => f a -> f b -> GOrdering a b
- Data.Dependent.Map: infixr 1 :=>
- Data.Dependent.Map: pattern Some :: forall k tag (a :: k). () => tag a -> Some tag

Files

ChangeLog.md view
@@ -1,6 +1,11 @@ # Revision history for dependent-map -## 0.3.1.0 - 2020-03-24+## 0.4.0.0 - 2020-03-26++* Stop re-exporting `Some(..)`, `GCompare(..)`, and `GOrdering(..)` from `dependent-sum` (which itself re-exports from `some` in some versions).+* Stop re-exporting `DSum(..)` from `dependent-sum`.++## 0.3.1.0 - 2020-03-26  * Drop support for non-GHC compilers. * Drop support for GHC < 8.
README.md view
@@ -1,34 +1,49 @@ dependent-map [![Build Status](https://travis-ci.org/obsidiansystems/dependent-map.svg)](https://travis-ci.org/obsidiansystems/dependent-map) [![Hackage](https://img.shields.io/hackage/v/dependent-map.svg)](http://hackage.haskell.org/package/dependent-map) ============== -This library defines a dependently-typed finite map type.  It is derived from Data.Map.Map in the containers package, but rather than (conceptually) storing pairs indexed by the first component, it stores `DSum`s (from the `dependent-sum` package) indexed by tag.  For example (using the types from the `dependent-sum` package's `FooGADT` example):+This library defines a dependently-typed finite map type. It is derived from `Data.Map.Map` in the `containers` package, but rather than (conceptually) storing pairs indexed by the first component, it stores `DSum`s (from the `dependent-sum` package) indexed by tag. For example  ```haskell+{-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE GADTs #-}-import FooGADT-import Data.Dependent.Map+{-# LANGUAGE MultiParamTypeClasses #-}+{-# LANGUAGE TemplateHaskell #-}+{-# LANGUAGE TypeFamilies #-}+module Example where -x = fromList [Foo :=> pi, Baz :=> "hello there"]-y = singleton Bar 42-z = union y (read "fromList [Foo :=> (-1.1415926535897931)]")+import Data.Constraint.Extras.TH (deriveArgDict)+import Data.Dependent.Map (DMap, fromList, singleton, union, unionWithKey)+import Data.Dependent.Sum ((==>))+import Data.Functor.Identity (Identity(..))+import Data.GADT.Compare.TH (deriveGCompare, deriveGEq)+import Data.GADT.Show.TH (deriveGShow) -addFoo :: Foo v -> v -> v -> v-addFoo Foo x y = x + y-addFoo _   x _ = x+data Tag a where+  StringKey :: Tag String+  IntKey    :: Tag Int+  DoubleKey :: Tag Double+deriveGEq ''Tag+deriveGCompare ''Tag+deriveGShow ''Tag+deriveArgDict ''Tag +x :: DMap Tag Identity+x = fromList [DoubleKey ==> pi, StringKey ==> "hello there"]++y :: DMap Tag Identity+y = singleton IntKey (Identity 42)++z :: DMap Tag Identity+z = y `union` fromList [DoubleKey ==> -1.1415926535897931]++addFoo :: Tag v -> Identity v -> Identity v -> Identity v+addFoo IntKey (Identity x) (Identity y) = Identity $ x + y+addFoo DoubleKey (Identity x) (Identity y) = Identity $ x + y+addFoo _ x _ = x++main :: IO () main = mapM_ print   [ x, y, z   , unionWithKey addFoo x z   ] ```--Which prints:--```haskell-fromList [Foo :=> 3.141592653589793,Baz :=> "hello there"]-fromList [Bar :=> 42]-fromList [Foo :=> -1.1415926535897931,Bar :=> 42]-fromList [Foo :=> 2.0,Bar :=> 42,Baz :=> "hello there"]-```--This library can be found on Hackage: https://hackage.haskell.org/package/dependent-map
dependent-map.cabal view
@@ -1,5 +1,5 @@ name:                   dependent-map-version:                0.3.1.0+version:                0.4.0.0 stability:              provisional  cabal-version:          >= 1.6
src/Data/Dependent/Map.hs view
@@ -11,8 +11,6 @@ {-# LANGUAGE UndecidableInstances #-} module Data.Dependent.Map     ( DMap-    , DSum(..), Some(..)-    , GCompare(..), GOrdering(..)      -- * Operators     , (!), (\\)@@ -152,7 +150,7 @@ import Data.GADT.Compare (GCompare, GEq, GOrdering(..), gcompare, geq) import Data.GADT.Show (GRead, GShow) import Data.Maybe (isJust)-import Data.Some (Some(..), mkSome)+import Data.Some (Some, mkSome) import Data.Typeable ((:~:)(Refl)) import Text.Read (Lexeme(Ident), lexP, parens, prec, readListPrec,                   readListPrecDefault, readPrec)@@ -175,7 +173,7 @@ {--------------------------------------------------------------------   Operators --------------------------------------------------------------------}-infixl 9 !,\\ --+infixl 9 \\,! -- \\ at the end of the line means line continuation  -- | /O(log n)/. Find the value at a key. -- Calls 'error' when the element can not be found.