[Haskell-cafe] Implementing ParseChart with Data.Map

Neil Mitchell ndmitchell at gmail.com
Mon Jun 2 18:41:30 EDT 2008


Hi

> case insertLookupWithKey (\_ -> Set.union) k (Set.singleton v) chart of
>  (Nothing, chart) -> Just chart
>  (Just set, chart) | Set.member v set -> Nothing
>                          | otherwise             -> Just chart
>
> but notice that the set is still traversed twice.

Yes, I missed that bit. I don't see any way of reducing that, other
than using an unsafePerformIO and IORef to track the combining
function - which is probably a really bad idea.

Thanks

Neil


More information about the Haskell-Cafe mailing list