Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Thanks to major contributions from @finnbar in 2025 to simplify the approach usi
The following shows an example:

{-# LANGUAGE DataKinds, TypeOperators, TypeFamilies, MultiParamTypeClasses #-}
{-# LANGUAGE TypeApplications #-}
import Data.Type.Map

-- Specifies how to combine duplicate key-value pairs for Int values
Expand All @@ -16,14 +17,14 @@ The following shows an example:
combine x y = x + y

foo :: Map '["x" :-> Int, "z" :-> Bool, "w" :-> Int]
foo = Ext (Var :: (Var "x")) 2
$ Ext (Var :: (Var "z")) True
$ Ext (Var :: (Var "w")) 5
foo = Ext (Var @"x") 2
$ Ext (Var @"z") True
$ Ext (Var @"w") 5
Empty

bar :: Map '["y" :-> Int, "w" :-> Int]
bar = Ext (Var :: (Var "y")) 3
$ Ext (Var :: (Var "w")) 1
bar = Ext (Var @"y") 3
$ Ext (Var @"w") 1
$ Empty

-- foobar :: Map '["w" :-> Int, "x" :-> Int, "y" :-> Int, "z" :-> Bool]
Expand Down
7 changes: 7 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# v0.9.1.0
- Expanded test suite to cover README examples
- Added tests for Map union with Combine behavior
- Added tests for Set examples with Natural numbers
- Uses [rearrangements](https://github.com/finnbar/rearrangements) library to simplify the implementation.
Comment thread
dorchard marked this conversation as resolved.
- Updated to GHC 9.8

# v0.9.0.0
- GHC 9.2 support
- Add Elem typeclass to retrieve the value at a type in a set
Expand Down
11 changes: 6 additions & 5 deletions examples/ExampleMap.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{-# LANGUAGE DataKinds, TypeOperators, TypeFamilies, MultiParamTypeClasses #-}
{-# LANGUAGE TypeApplications #-}

module ExampleMap where

Expand All @@ -12,17 +13,17 @@ instance Combinable Int Int where
combine x y = x + y

foo :: Map '["x" :-> Int, "z" :-> Bool, "w" :-> Int]
foo = Ext (Var :: (Var "x")) 2
$ Ext (Var :: (Var "z")) True
$ Ext (Var :: (Var "w")) 5
foo = Ext (Var @"x") 2
$ Ext (Var @"z") True
$ Ext (Var @"w") 5
$ Empty

foo' :: Map (AsMap '["z" :-> Bool, "x" :-> Int, "w" :-> Int])
foo' = asMap foo

bar :: Map '["y" :-> Int, "w" :-> Int]
bar = Ext (Var :: (Var "y")) 3 $
Ext (Var :: (Var "w")) 1 $
bar = Ext (Var @"y") 3 $
Ext (Var @"w") 1 $
Empty

-- GHC can easily infer this type, so an explicit signature not necessary
Expand Down
2 changes: 1 addition & 1 deletion type-level-sets.cabal
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: type-level-sets
version: 0.9.0.0
version: 0.9.1.0
synopsis: Type-level sets and finite maps (with value-level counterparts)
description:
This package provides type-level sets (no duplicates, sorted to provide a normal form) via 'Set' and type-level
Expand Down
Loading