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. Re: Ambiguous type error: multiparam class + type alias
(Sylvain Henry)
----------------------------------------------------------------------
Message: 1
Date: Thu, 28 Sep 2017 12:58:16 +0200
From: Sylvain Henry <[email protected]>
To: [email protected]
Subject: Re: [Haskell-beginners] Ambiguous type error: multiparam
class + type alias
Message-ID: <[email protected]>
Content-Type: text/plain; charset=utf-8; format=flowed
On 28/09/2017 12:25, Baa wrote:
> Hello, Sylvain.
>
> Your solution assumes that I need to pass `@_ @AsTitle` anywhere where I
> call `repr`? So, instead of `repr n::AsTitle` or `repr n::Something AsTitle`
> (depends on implementation) I'll write `repr @_ @AsTitle n`, right?
Yes.
You could also avoid all this ambiguity/type application stuff with:
data AsTitle = AsTitle
class Repr a b where
repr :: a -> b -> Repr b
instance Repr Int AsTitle where
repr n _ = ...
...
print (repr n AsTitle)
(Repr b can be an associated type if you want to support different
representations)
>
>> You only add a constraint as follows:
>> repr n :: forall b. (Repr b ~ Repr AsTitle, ReprC Int b) => Repr b
> Yes... So, `b` is unbound/free type param. But I can bind it with func.
> deps, yes?
How? If you you bind it with a functional dependency on "a", you can
only have a single "b" for each "a".
Sylvain
------------------------------
Subject: Digest Footer
_______________________________________________
Beginners mailing list
[email protected]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
------------------------------
End of Beginners Digest, Vol 111, Issue 20
******************************************