[Haskell-cafe] Functions from Data.Hashtable

wren ng thornton wren at freegeek.org
Tue Apr 7 18:46:33 EDT 2009

Peter Verswyvelen wrote:
> These functions have their arguments reversed when compare to e.g. Map
> For example
> Data.HashTable.lookup :: HashTable key val -> key -> IO (Maybe val)
> Data.Map.lookup :: Ord key => key -> Map key val -> Maybe val
> I find this a bit odd. Is this by design?

I'd guess it's due more to antiquity than to intention. Data.Map mirrors 
the Prelude, along with almost everyone else:

GHC.List.lookup :: (Eq a) => a -> [(a, b)] -> Maybe b

Data.IntMap.lookup :: (Monad m) => Data.IntMap.Key -> IntMap a -> m a

Data.Trie.lookup :: ByteString -> Trie a -> Maybe a

Data.Set.member :: (Ord a) => a -> Set a -> Bool

As a design issue, I think the dominant order is better for partial 
application since they make good arguments to Control.Monad.State.gets 
and similar state-like HOFs. Considering the IO ugliness of HashTable, 
Jason Dagit may have a point though. As I recall, this discussion has 
lead to flame wars in the past.

Live well,

More information about the Haskell-Cafe mailing list