forall type gives "not polymorphic enough" error incorrectly
> type SFST s a b = a -> ST s b
> newtype SF a b = SF { runSF :: forall s. ST s (SFST s a b) }
When making this into an instance of Arrow, compose works beautifully:
> sfCompose :: SF b c -> SF c d -> SF b d
> sfCompose bc cd = SF sf where
> sf = do
> runBc <- runSF bc
> runCd <- runSF cd
> return $ \b -> runBc b >>= runCd
but pure gives an odd message:
> sfPure :: (b -> c) -> SF b c
> sfPure f = SF sf where
> sf = return $ \b -> return (f b)
frp_typebug.lhs:20:12:
Inferred type is less polymorphic than expected
Quantified type variable `s' is mentioned in the environment:
sf :: ST s (b -> ST s c) (bound at frp_typebug.lhs:21:5)
In the first argument of `SF', namely `sf'
In the expression: SF sf
In the definition of `sfPure':
sfPure f = SF sf
where
sf = return $ (\ b -> return (f b))
This can be worked around using scoped type variables:
> sfPure2 :: (b -> c) -> SF b c
> sfPure2 (f :: b -> c) = SF sf where
> sf :: forall s. ST s (SFST s b c)
> = return $ \b -> return (f b)
but it's ugly.