[Haskell-cafe] Manual type-checking in graphs: Avoidable?

Johannes Waldmann johannes.waldmann at htwk-leipzig.de
Fri Feb 19 11:07:14 UTC 2016


> .. a graph that described which people own which hamsters,

This is a bipartite graph, or, a relation. You want a type like

data Rel src tgt a =
  Rel { fore :: ! ( M.Map src (M.Map tgt a) )
      , back :: ! ( M.Map tgt (M.Map src a) )
      }

where src = People, tgt = Hamster, and a = Bool.
In general, a  could be some extra weight information.

- J.W.

cf.
https://gitlab.imn.htwk-leipzig.de/waldmann/pure-matchbox/blob/master/src/Matchbox/Relation.hs



More information about the Haskell-Cafe mailing list