Yep, that fixed it.. Thanks, Brandon. Michael --- On Tue, 4/28/09, Brandon S. Allbery KF8NH <allbery@ece.cmu.edu> wrote: From: Brandon S. Allbery KF8NH <allbery@ece.cmu.edu> Subject: Re: [Haskell-cafe] chr/ord? To: "michael rice" <nowgate@yahoo.com> Cc: "Brandon S. Allbery KF8NH" <allbery@ece.cmu.edu>, "Tim Wawrzynczak" <inforichland@gmail.com>, "Lennart Augustsson" <lennart.augustsson@gmail.com>, "haskell-cafe@haskell.org" <haskell-cafe@haskell.org> Date: Tuesday, April 28, 2009, 11:44 PM On Apr 28, 2009, at 23:32 , michael rice wrote:Thank guys, Now what am I misunderstanding in the code below? lst = [('A',65),('B',66),('C',67),('D',68)] You didn't give a type for lst, so it defaulted to [(Char,Integer)]. This is a manifestation of the Monomorphism Restriction, invoked because lst doesn't take any arguments: it forces lst to have a definite type, so defaulting is used to fix the numeric part to Integer. If you add a type specification for lst, things will work as you expect. -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.comsystem administrator [openafs,heimdal,too many hats] allbery@ece.cmu.eduelectrical and computer engineering, carnegie mellon university KF8NH
Michael Rice wrote:
-- comb is a combinator for sequencing operations that return Maybe comb :: Maybe a -> (a -> Maybe b) -> Maybe b comb Nothing _ = Nothing comb (Just x) f = f x
comb is essentially the same as something in the Prelude: it is just (>>=) specialized to Maybe. (>>=) :: Monad m => m a -> (a -> m b) -> m b
Now what am I misunderstanding in the code below? lst = [('A',65),('B',66),('C',67),('D',68)]
Brandon S. Allbery wrote:
...it defaulted to [(Char,Integer)]. This is a manifestation of the Monomorphism Restriction...
While it may be debatable whether the Monomorphism Restriction is helpful in compiled code, it is unquestionably a major nuisance at the GHCi prompt, for this and other reasons. I highly recommend that you create a .ghci file in your home directory containing the line: :set -XNoMonomorphismRestriction In my opinion, MR should be off by default in GHCi. -Yitz
participants (2)
-
michael rice -
Yitzchak Gale