fromTransitionMap :: TransitionMap -> MarkovChain
fromTransitionMap m =
  M.fromList [(k, frequencies k) | k <- ks]
  where ks = L.nub $ map fst $ M.keys m
        frequencies a = map reduce $ filter (outboundFor a) $ M.toList m
        outboundFor a k = fst (fst k) == a
        reduce e = (snd (fst e), snd e)
fromTransitionMap :: TransitionMap -> MarkovChain
fromTransitionMap m =
  M.fromList [(k, frequencies k) | k <- ks]
  where ks = L.nub $ map fst $ M.keys m
        frequencies a = map reduce $ filter (outboundFor a) $ M.toList m
        outboundFor a k = fst (fst k) == a
        reduce e = (snd (fst e), snd e)
fromTransitionMap m =
  M.fromList [(k, frequencies k) | k <- ks]
  where ks = L.nub $ map fst $ M.keys m
        frequencies a = map reduce $ filter (outboundFor a) $ M.toList m
        outboundFor a k = fst (fst k) == a
        reduce e = (snd (fst e), snd e)