Send Beginners mailing list submissions to
        beginners@haskell.org

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
        beginners-requ...@haskell.org

You can reach the person managing the list at
        beginners-ow...@haskell.org

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 <sylv...@haskus.fr>
To: beginners@haskell.org
Subject: Re: [Haskell-beginners] Ambiguous type error: multiparam
        class + type alias
Message-ID: <2aab4bd9-f22c-e738-b467-1d9b7542f...@haskus.fr>
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
Beginners@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners


------------------------------

End of Beginners Digest, Vol 111, Issue 20
******************************************

Reply via email to