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 (Daniel Fischer)
2. Re: More on trying to install Haskell platform on Lion...
(Stuart Hungerford)
----------------------------------------------------------------------
Message: 1
Date: Wed, 7 Mar 2012 01:55:06 +0100
From: Daniel Fischer <[email protected]>
Subject: Re: [Haskell-beginners] Ambiguous MonadIO and Monad
To: [email protected]
Message-ID: <[email protected]>
Content-Type: Text/Plain; charset="iso-8859-1"
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.
------------------------------
Message: 2
Date: Wed, 7 Mar 2012 12:41:57 +1100
From: Stuart Hungerford <[email protected]>
Subject: Re: [Haskell-beginners] More on trying to install Haskell
platform on Lion...
To: Brandon Allbery <[email protected]>
Cc: [email protected]
Message-ID:
<cag+kmrgnampk3kbxwbcgpvcmc+ppmjr+jogyhgnf06t+9hy...@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1
On Wed, Mar 7, 2012 at 9:20 AM, Brandon Allbery <[email protected]> wrote:
> [...]
> The problem is not Lion, it is that
>
> (a) Xcode 4.3 was only just released
> (b) Apple does not allow details of unreleased software to be discussed etc.
> before release
> which means
> (c) everyone who relies on Xcode got pretty much blindsided by all the
> changes.
>
> ghc hasn't quite caught up with the changes yet. ?MacPorts is still
> struggling with some issues involved with the release; I don't know where
> Homebrew is with respect to it. ?Some of the other projects I'm involved
> with aren't Mac focused, and are just starting to realize that there are
> problems with Xcode 4.3 support.
>
> If you need Haskell Platform working ASAP on OS X, remove Xcode 4.3, then
> download Xcode 4.2.1 from http://connect.apple.com/.
Thanks -- that sounds like a good approach. In the meantime I did find
that building ghc and haskell-platform with Homebrew and the
"--use-llvm" switch worked without errors, but I don't know enough
about Haskell yet to tell if the result is useable.
My long term goal is to install the Diagrams package, which needs GTK,
Cairo etc. From what I've found so far that seems to be a serious
undertaking too (although I'd be delighted to be corrected on that).
Thanks,
Stu
------------------------------
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
End of Beginners Digest, Vol 45, Issue 6
****************************************