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:  Confused by type constraints (Guy)
   2. Re:  Function definition order and performance
      (Aleksandar Dimitrov)


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

Message: 1
Date: Tue, 07 Jun 2011 12:30:58 +0300
From: Guy <[email protected]>
Subject: Re: [Haskell-beginners] Confused by type constraints
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

On 07/06/2011 12:03, Daniel Fischer wrote:
> On Tuesday 07 June 2011, 10:51:00, Guy wrote:
>> On 06/06/2011 17:31, Daniel Schoepe wrote:
>>> On Sun, 05 Jun 2011 19:53:50 +0300, Guy<[email protected]>
> wrote:
>>>> So in my original example, why isn't "instance Foo (Bar f)"
>>>> destructing Bar - and making the constraint available?
>>>
>>> The "Bar" in "instance Foo (Bar f)" is a type constructor, not a data
>>> constructor like the X in "s (X x)". Hence "instance Foo (Bar f)"
>>> isn't really deconstructing anything, but applying the type
>>> constructor Bar to f, whereas "s (X x)" matches a _value_ of type X.
>>>
>>> This might be a bit clearer if you name type and data constructors
>>> differently, e.g.:
>>>
>>> data Bar f a = Foo f =>   MkBar { bar :: f a }
>>>
>>> Cheers,
>>> Daniel
>>
>> Thanks, I (think I) understand your explanation, but ... why can't GHC
>> infer that Bar must always be a Show, seeing as this is the only
>> constructor?
>
> undefined :: Bar f a
>
> You get the Foo constraint from the constructor MkBar, but there is a value
> which doesn't use the constructor, so you can't get it from the type alone.

So if GHC were to infer the type constraint, it could be violated by undefined. 
Would this prevent any real code from 
working?




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

Message: 2
Date: Tue, 7 Jun 2011 11:58:08 +0200
From: Aleksandar Dimitrov <[email protected]>
Subject: Re: [Haskell-beginners] Function definition order and
        performance
To: Daniel Fischer <[email protected]>
Cc: [email protected]
Message-ID: <20110607095808.GE11919@minsk>
Content-Type: text/plain; charset="utf-8"

On Tue, Jun 07, 2011 at 10:59:26AM +0200, Daniel Fischer wrote:
> On Tuesday 07 June 2011, 10:33:08, Aleksandar Dimitrov wrote:
> > Note that the only thing interesting here is that safeHead' got
> > translated to safeHeadzq, which is? well. Cute, and nothing else.
> 
> It's z-encoding, 
> http://hackage.haskell.org/trac/ghc/wiki/Commentary/Compiler/SymbolNames
> 
> Kind of irritating when you come across a z-encoded name containing a z 
> where you don't expect z-encoding.

Well, that's outright adorable. I knew there had to be some systematic trickery
behind this; thanks for sharing :-)

Regards,
Aleks
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 490 bytes
Desc: Digital signature
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20110607/6299b71c/attachment-0001.pgp>

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

_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners


End of Beginners Digest, Vol 36, Issue 18
*****************************************

Reply via email to