Thanks for the report, but I think I can explain this.

Firstly, and quite unrelatedly, you can use triple braces to request monospace, see my edit to the description.

'sf' has no arguments, so the monomorphism restriction applies. The body of 'sf' is assigned a typing derivation of the form:

Monad m1, Monad m2, f :: b -> c |- return $ \b -> return (f b) : m1 (a -> m2 b)

Because 'm1' and 'm2' are constrained by type classes, the monomorphism restriction forces them to be assigned to fully non-polymorphic types; unfortunately this means that it is insufficiently polymorphic for SF.

Possible workarounds include:

{-# LANGUAGE NoMonomorphismRestriction #-}
-- for older GHC, {-# OPTIONS_GHC -fno-monomorphism-restriction #-}

or:

sfPure :: (b -> c) -> SF b c
sfPure f = SF sf where
returnST :: a -> ST s a
returnST = return
sf = returnST $ \b -> returnST (f b) -- no type classes, no MR

or the aforementioned explicit annotation approach (explicit annotations disable the MR).

Unfortunately, the monomorphism restriction is specified by the Haskell 98 Language Report, so you're more likely to get results from the Haskell-prime committee than you are from specific implementors.

Stefan