Send Beginners mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
http://mail.haskell.org/cgi-bin/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. How do ambigious types compile with Aeson (Sevcsik Andr?s)
2. Re: How do ambigious types compile with Aeson (Brandon Allbery)
3. Re: How do ambigious types compile with Aeson (Sevcsik Andr?s)
----------------------------------------------------------------------
Message: 1
Date: Sun, 13 Sep 2015 01:15:43 +0000
From: Sevcsik Andr?s <[email protected]>
To: "[email protected]" <[email protected]>
Subject: [Haskell-beginners] How do ambigious types compile with Aeson
Message-ID:
<cac+tgn7a2vnx2k-xvgyv_3bbjqqcpivdz55qpooeiigcwmn...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
Hi list,
> ghci> decode $ fromStrict $ encodeUtf8 $ "{\"a\" : \"b\"}"
> Nothing
> ghci> decode $ fromStrict $ encodeUtf8 $ "{\"a\" : \"b\"}" :: Maybe Object
> Just (fromList [("a",String "b")])
The question is: how can the first example compile? I would expect that
since GHC cannot infer the type I want from Aeson to decode to, it would
die with an error that "t0 type variable is ambigious". But instead, it
compiles just fine, and fails runtime.
How it's decided what type should Aeson try to decode to? What type is that
gives me Nothing on whatever JSON input I give?
Cheers,
Andras Sevcsik
--
Minden j?t,
Sevcsik Andr?s
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20150913/f8c03668/attachment-0001.html>
------------------------------
Message: 2
Date: Sat, 12 Sep 2015 21:19:52 -0400
From: Brandon Allbery <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] How do ambigious types compile with
Aeson
Message-ID:
<cakfcl4upv_vkqp3xv3xpruxx-euw0-3bmhv74-bhbdrokep...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
On Sat, Sep 12, 2015 at 9:15 PM, Sevcsik Andr?s <[email protected]> wrote:
> How it's decided what type should Aeson try to decode to? What type is
> that gives me Nothing on whatever JSON input I give?
ghci has ExtendedDefaultRules enabled, which means that many things will
infer a type of () if one cannot otherwise be determined. This is not
something Aeson has control over.
Try ":seti -XNoExtendedDefaultRules" and ask ghci again; it should produce
an ambiguous type error.
--
brandon s allbery kf8nh sine nomine associates
[email protected] [email protected]
unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20150912/127c9329/attachment-0001.html>
------------------------------
Message: 3
Date: Sun, 13 Sep 2015 01:59:05 +0000
From: Sevcsik Andr?s <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] How do ambigious types compile with
Aeson
Message-ID:
<CAC+TGN413iL-h_aARZ_5-VnJzbG0QuzTf_SumVn07sotPXh=w...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
That explains it, thank you!
On Sun, Sep 13, 2015, 03:20 Brandon Allbery <[email protected]> wrote:
> On Sat, Sep 12, 2015 at 9:15 PM, Sevcsik Andr?s <[email protected]> wrote:
>
>> How it's decided what type should Aeson try to decode to? What type is
>> that gives me Nothing on whatever JSON input I give?
>
>
> ghci has ExtendedDefaultRules enabled, which means that many things will
> infer a type of () if one cannot otherwise be determined. This is not
> something Aeson has control over.
> Try ":seti -XNoExtendedDefaultRules" and ask ghci again; it should produce
> an ambiguous type error.
>
> --
> brandon s allbery kf8nh sine nomine
> associates
> [email protected]
> [email protected]
> unix, openafs, kerberos, infrastructure, xmonad
> http://sinenomine.net
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
--
Minden j?t,
Sevcsik Andr?s
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20150913/f1a248b4/attachment-0001.html>
------------------------------
Subject: Digest Footer
_______________________________________________
Beginners mailing list
[email protected]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
------------------------------
End of Beginners Digest, Vol 87, Issue 5
****************************************