Last active
March 13, 2019 16:20
-
-
Save johnynek/774a7bffeaa3c69e196c9388d3eafae9 to your computer and use it in GitHub Desktop.
A module based encoding of Map which keeps the ordering associated with the Map. Then we can talk about `mymod.Map` as a type, knowing that `mymod.ordering` is the ordering.
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
abstract class MapModule { | |
type K | |
def ordering: Ordering[K] | |
type Map[_] | |
def empty[V]: Map[V] | |
def updated[V](m: Map[V], key: K, v: V): Map[V] | |
def get[V](m: Map[V], key: K): Option[V] | |
def items[V](m: Map[V]): Stream[(K, V)] | |
def remove[V](m: Map[V], key: K): Map[V] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment