
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Here is return's type signature: return :: Monad m => a -> m a What you are doing with the do notation can also be expressed as ioStr
= (\str -> return str).
do notation and bind both require you to have a value that has the same monad as before. Steven Williams My PGP Key: http://pgp.mit.edu/pks/lookup?op=get&search=0xCACA6C74669A54 FA On 10/06/15 12:35, Mike Houghton wrote:
Hi,
I’ve been tryimg to write a function with signature
asString :: IO String -> String
Does someone please have the patience to explain to me what the compiler error messages really mean for these two attempts and exactly what I’m doing (!!!) If I *do not* give this function any type signature then it works i.e..
asString ioStr = do str <- ioStr return $ str
and the compiler tells me its signature is
asString :: forall (m :: * -> *) b. Monad m => m b -> m b
which, at this stage of my Haskell progress, is just pure Voodoo. Why isn’t it’s signature asString :: IO String -> String ?
Another naive attempt is asString ioStr = str where str <- ioStr
and then compiler says parse error on input ‘<-’
Many Thanks
Mike
_______________________________________________ Beginners mailing list Beginners@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
-----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBAgAGBQJVeGo5AAoJEMrKbHRmmlT6N8UP/i/tAhDtyHiG3sgH3e5xAqyt JAsyX2JaBQVjERRVaJQy1+Pg9hNdGBCrVljxY0BH5B8np956bnuIEyZKtSc2i2Jc HM0lBesyzCYqw29QxAyFFno07iXQllocZaHUIgC4AoNYO5zNGSPYcNaB4O5SYoKl 83Cjz97BHgAHkvHpsLDLOpizOkP+CsXwi8s/KRKoidLkbQpmv9SpqiFvmm9u+UK1 emZF/4veFE4Ay3AvIsxMpn7M5hVoKgat1xyGX02IrenvkOL69IIYc+4OvzK49Lxg e8jrAehJDMh+U7zN+qVCY1ZyJbJF+uGawFC+XoswOdAra+Q23te77RKkligkmN7s ACut72hwTejZN/sIaORqZXuy+HUY1LjlJnlz0RCdG1CLkr3EaKG5ZCX3E2N8RnxL 1CKtEdtFJGDeBcIBh5my/7IC22loTpVhBhPU2DPo+iOP2sRsUs0nllbqbjGfGpuE m37dR/tfq9FKwqYS5RUuAcZ8fWuPdojmO2WvI4thHBGJhsRK4gqhAI4MnKLHBEoL xfyHSaoFif/jC7peF/+ZPjKSsIpCJU+R/tDUBM9u22o3IVeTs1sWGZXM7J32tlGc K/MTF/F3phcxwSCqb99WBHhXOIkKSgp47gx1INgDZFug/CgjUI1Sl4jvZ5j/45D5 +RlHcYv+qp4J8nI59pFW =Vunc -----END PGP SIGNATURE-----