Created
September 16, 2017 21:16
-
-
Save jmitchell/fc911e7cdce12109de7919a88abbff13 to your computer and use it in GitHub Desktop.
Key-value mapping in Idris where set of keys that have values is encoded in the type
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Data.List | |
data SetMap : List k -> Type -> Type where | |
Empty : SetMap [] _ | |
Insert : DecEq k => | |
(key : k) -> | |
v -> | |
SetMap keys v -> | |
{auto prf : isElem key keys = No _} -> | |
SetMap (key :: keys) v | |
example : SetMap ["a", "b"] Nat | |
example = Insert "a" 2 $ | |
Insert "b" 1 $ | |
Empty |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment