Send Beginners mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
http://www.haskell.org/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."
Today's Topics:
1. Re: Ambiguous MonadIO and Monad (Ken KAWAMOTO)
2. Re: Installing Haskell on Lion with Homebrew... (Jack Henahan)
----------------------------------------------------------------------
Message: 1
Date: Thu, 8 Mar 2012 01:50:06 +0900
From: Ken KAWAMOTO <[email protected]>
Subject: Re: [Haskell-beginners] Ambiguous MonadIO and Monad
To: Daniel Fischer <[email protected]>,
[email protected]
Message-ID:
<CAGByEKNoOjKCxvtghHW2eEG95ZmBOA2C3=sre+ts-abhfz-...@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1
Thanks Daniel.
Adding a type signature to response did resolve the issue.
The monomorphism restriction
(http://www.haskell.org/haskellwiki/Monomorphism_restriction)
is still a bit hard for me, but I'll definitely add type signatures to
all top-level defs to avoid this kind of issues.
-- Ken
On Wed, Mar 7, 2012 at 9:55 AM, Daniel Fischer
<[email protected]> wrote:
> On Wednesday 07 March 2012, 00:42:05, Ken KAWAMOTO wrote:
>> Hi,
>>
>> I'm trying to understand how Network.OAuth.Consumer works, and
>> run sample code found here with Twitter API. (the full code is
>> attached at the bottom)
>> http://hackage.haskell.org/packages/archive/hoauth/0.3.3/doc/html/Networ
>> k-OAuth-Consumer.html
>>
>> When I load the test code with GHCi 7.0.2, it raises error:
>>
>> --- Error message begin
>> TestOAuth.hs:21:103:
>> ? ? Ambiguous type variable `m0' in the constraints:
>> ? ? ? (MonadIO m0) arising from a use of `serviceRequest'
>> ? ? ? ? ? ? ? ? ? ?at TestOAuth.hs:21:103-116
>> ? ? ? (Monad m0) arising from a use of `>>=' at TestOAuth.hs:21:99-101
>> ? ? Possible cause: the monomorphism restriction applied to the
>> following: response :: m0 Response (bound at TestOAuth.hs:17:1)
>> ? ? Probable fix: give these definition(s) an explicit type signature
>> ? ? ? ? ? ? ? ? ? or use -XNoMonomorphismRestriction
>> ? ? In the second argument of `(>>=)', namely
>
>>
>> I seem using NoMonomorphismRestriction is workaround, so I want to add
>> a proper type signature, but I cannot figure out what it is.
>>
>> What confuses me is why GHC didn't just take MonadIO as MonadIO is a
>> Monad according to the definition.
>
> From the definition of response, the two constraints
>
> MonadIO m0
> Monad m0
>
> are inferred. Since response is bound by a simple pattern binding (no
> function arguments) and without a type signature, by the monomorphism
> restriction, it must get a monomorphic type, so the compiler tries to find
> a specific MonadIO (and Monad, but that would follow) to use. But there is
> no defaulting for those constraints (defaulting takes place for constraints
> where at least one of the involved classes is a numeric class [Num,
> Integral, Fractional, ...], and all involved classes are defined in the
> standard libraries), so that fails (no numeric class, and MonadIO is
> defined outside the standard libraries).
>
> To fix it, you just have to define response with a type signature,
>
> response :: MonadIO m => m Response
>
> You should give all your top-level definitions type signatures anyway. It's
> good for documentation, and it gives you much better error messages if you
> make a mistake.
--
Ken KAWAMOTO
[email protected]
------------------------------
Message: 2
Date: Wed, 7 Mar 2012 17:19:34 -0500
From: Jack Henahan <[email protected]>
Subject: Re: [Haskell-beginners] Installing Haskell on Lion with
Homebrew...
To: Stuart Hungerford <[email protected]>
Cc: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset="us-ascii"
I recommend installing outside homebrew, really. If you want the platform, I'd
go with the pkg installer on the site, but I usually bootstrap the bindist from
here.[1] I configure it to be in its own prefix in my home directory and to use
the GMP from homebrew. If you'd like to go that way, let me know and I'll see
if I can dig up the proper methods to get the newest cabal-install, as well. A
few configs need fiddling, but other than that it's painless.
Additionally, have you tried the homebrew install with particular compiler
choices? Try --use-clang (I'm pretty sure it uses LLVM by default, but if clang
doesn't work you can always pass it --use-llvm. You never know.).
[1]:http://www.haskell.org/ghc/download_ghc_7_4_1#macosx_x86_64
Jack Henahan
[email protected]
==
Computer science is no more about computers than astronomy is about telescopes.
-- Michael R. Fellows
==
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PublicKey.asc
Type: application/x-apple-msg-attachment
Size: 24255 bytes
Desc: not available
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20120307/d1b62ead/attachment.bin>
-------------- next part --------------
On Mar 6, 2012, at 2:57 AM, Stuart Hungerford wrote:
> Hi,
>
> I'd like to start using Haskell on my OS/X Lion system. In
> preparation I've installed 10.7.3 and the latest XCode. I've also
> installed the XCode command line tools.
>
> I'm using Homebrew and run "brew doctor" first to make sure Homebrew
> is happy. Then a "brew install haskell-platform" generates thousands
> of "ld: warning: text reloc in _cZh_str to _stg_ap_pppppp_info"
> warnings then fails on C Compiler errors.
>
> I must have missed something important? Any advice from other OS/X
> Lion users much appreciated.
>
> Thanks,
>
> Stu
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 841 bytes
Desc: Message signed with OpenPGP using GPGMail
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20120307/d1b62ead/attachment.pgp>
------------------------------
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
End of Beginners Digest, Vol 45, Issue 7
****************************************