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: Offside rule for function arguments? (John Smith)
   2.  Classes in Polymorphic Constructors (John Smith)
   3.  Re: Classes in Polymorphic Constructors (Ertugrul Soeylemez)
   4.  Re: Classes in Polymorphic Constructors (John Smith)


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

Message: 1
Date: Mon, 23 Aug 2010 12:54:25 +0300
From: John Smith <[email protected]>
Subject: [Haskell-beginners] Re: Offside rule for function arguments?
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Sorry, I missed the where.

On 23/08/2010 12:52, Jonas Almström Duregård wrote:
>  > The indentation on the second line would generate a parse error, the same 
> as it does now.
> What parser error is that? Both
>
> function 0 = 0 where
>   fun     1 = 1
> function 2 = 2
>
> and
>
> function 0 = 0 where
>   fun     1 = 1
>   fun     2 = 2
>
> works for me.
>
> /J
>
> On 23 August 2010 11:46, John Smith <[email protected] 
> <mailto:[email protected]>> wrote:
>
>     The indentation on the second line would generate a parse error, the same 
> as it does now.
>
>
>     On 23/08/2010 12:32, Jonas Almström Duregård wrote:
>
>         Maybe because of this:
>
>         function 0 = 0 where
>           fun     1 = 1
>                   2 = 2
>
>         The last declaration (2=2) can define either fun or function. I'm not 
> saying this is a major problem, but there
>         may be
>         other problems like these.
>
>         /J
>
>         On 23 August 2010 11:15, Brent Yorgey <[email protected] 
> <mailto:[email protected]>
>         <mailto:[email protected] <mailto:[email protected]>>> 
> wrote:
>          > On Mon, Aug 23, 2010 at 09:33:13AM +0300, John Smith wrote:
>          >> Why doesn't Haskell allow something like this?
>          >>
>          >> fac 0 = 0
>          >>     1 = 1
>          >>     x = x * fac (x-1)
>          >>
>          >> This would be clearer than repeating the function name each time,
>          >> and follow the same pattern as guards and case.
>          >
>          > Good question.  I don't know of any particular reason.
>          >
>          > -Brent



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

Message: 2
Date: Mon, 23 Aug 2010 15:31:42 +0300
From: John Smith <[email protected]>
Subject: [Haskell-beginners] Classes in Polymorphic Constructors
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Why can polymorphic data constructors not be instantiated as a class? (not sure 
if I used the right terminology there)

For example,

a = [1,True]::[Show]
b = "foo":a
c = map show b

This would obviate the need for wrapper types



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

Message: 3
Date: Mon, 23 Aug 2010 17:32:19 +0200
From: Ertugrul Soeylemez <[email protected]>
Subject: [Haskell-beginners] Re: Classes in Polymorphic Constructors
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=US-ASCII

John Smith <[email protected]> wrote:

> Why can polymorphic data constructors not be instantiated as a class?
> (not sure if I used the right terminology there)
>
> For example,
>
> a = [1,True]::[Show]
> b = "foo":a
> c = map show b
>
> This would obviate the need for wrapper types

Your type signature doesn't make sense.  You are confusing type classes
with types.  Show is a type class.

As far as I see, you will need a wrapper type:

  data Object = forall a. Show a => Object { unObject :: a }

  a = [Object 1, Object True]
  b = Object "foo" : a
  c = map (show . unObject) b

I have not tested this code, though.  At least I can get the following
list to type-check (using RankNTypes and ImpredicativeTypes extensions):

  [1,2,3] :: [forall a. Num a => a]

but I can't use it in any way.  And somehow I also can't mix data types
here.


Greets,
Ertugrul


-- 
nightmare = unsafePerformIO (getWrongWife >>= sex)
http://ertes.de/




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

Message: 4
Date: Mon, 23 Aug 2010 19:12:36 +0300
From: John Smith <[email protected]>
Subject: [Haskell-beginners] Re: Classes in Polymorphic Constructors
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

On 23/08/2010 18:32, Ertugrul Soeylemez wrote:
> John Smith<[email protected]>  wrote:
>
>> Why can polymorphic data constructors not be instantiated as a class?
>> (not sure if I used the right terminology there)
>>
>> For example,
>>
>> a = [1,True]::[Show]
>> b = "foo":a
>> c = map show b
>>
>> This would obviate the need for wrapper types
>
> Your type signature doesn't make sense.  You are confusing type classes
> with types.  Show is a type class.

My question was why doesn't the type system allow classes to be used in this 
way. It's the equivalent of a base class or 
interface in OO.



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

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


End of Beginners Digest, Vol 26, Issue 45
*****************************************

Reply via email to