I\'m playing with http://hackage.haskell.org/packages/archive/vault/0.2.0.0/doc/html/Data-Vault-ST.html and want to write functions like the following:
onVau
You need to give onVault
and onVault2
rank 2 types.
{-# LANGUAGE Rank2Types #-} -- RankNTypes would also work
onVault :: (forall s. Key s a -> b) -> b
onVault2 :: (forall s. Key s a -> Key s b -> c) -> c
This is because runST :: (forall s. ST s a) -> a
requires that the passed action is polymorphic in the state thread parameter s
, which is a type-level trick used to guarantee purity. See the ST monad article on HaskellWiki for details.