As explained in #5, an Elm Dict needs the type of its keys to be comparable, and only a few primitive types are comparable. Because of that, it is not possible to use the core containers (Set, Dict) with user-defined data types.
It is more efficient to update a Dict a b than a -> b. That's why I find that a well-behaved dictionary structure could help us to define Graphs. It is easier to update with new edges and vertices.
An alternative approach is just to maintain the same a -> b and to do the updates as follows:
update : (a -> b) -> a -> b -> (a -> b)
update f x y z = if z == x then y else (f z)
As explained in #5, an Elm
Dict
needs the type of its keys to be comparable, and only a few primitive types are comparable. Because of that, it is not possible to use the core containers (Set, Dict) with user-defined data types.It is more efficient to update a
Dict a b
thana -> b
. That's why I find that a well-behaved dictionary structure could help us to define Graphs. It is easier to update with new edges and vertices.An alternative approach is just to maintain the same
a -> b
and to do the updates as follows: