[Haskell-beginners] Re: monad nomad gonad gomad

Brandon S Allbery KF8NH allbery at ece.cmu.edu
Sat Aug 14 22:07:39 EDT 2010


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 8/14/10 19:51 , prad wrote:
> mkTxt :: (IConnection conn) => conn -> String -> [String]
(...)
> the compiler produces what is to me an incomprehensible rationale for
> an error:
> 
> ====
>  gadit.hs:103:4:
>     Couldn't match expected type `IO String'
>            against inferred type `[String]'

You didn't specify that mkTxt is in IO; your result type is [String], which
(given your use of the monad machinery) means you return a String in the
List monad.  So, "(zzzz :: String) <- (readFile "zzPubs.htm" :: IO String)",
but because of the List monad in the result type this means that it's
expecting a [String], not an IO String.

- -- 
brandon s. allbery     [linux,solaris,freebsd,perl]      allbery at kf8nh.com
system administrator  [openafs,heimdal,too many hats]  allbery at ece.cmu.edu
electrical and computer engineering, carnegie mellon university      KF8NH
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.10 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkxnS+sACgkQIn7hlCsL25XmGQCgrhMM6vCzRNMH4deG41od7eD3
l9cAn0a+WbwvkAWC7ikG9mFB6ybIjTKa
=Voo5
-----END PGP SIGNATURE-----


More information about the Beginners mailing list