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:  Type unions (Guofeng Zhang)
   2. Re:  Type unions (Thomas Davie)
   3. Re:  Type unions (aditya siram)
   4.  haven (jean verdier)
   5. Re:  Type unions (Daniel Fischer)
   6. Re:  haven (Daniel Fischer)
   7. Re:  haven (Stephen Tetley)
   8.  mapping over newtypes (Tim Baumgartner)


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

Message: 1
Date: Wed, 15 Dec 2010 22:15:16 +0800
From: Guofeng Zhang <[email protected]>
Subject: Re: [Haskell-beginners] Type unions
To: beginners <[email protected]>
Message-ID:
        <[email protected]>
Content-Type: text/plain; charset="iso-8859-1"

What does "$" mean in Left $ A x. Why does not write it as "Left A x"?

For putStrLn $ "welcome", is the "$" has the same meaning as that in Left $
A x?


On Wed, Dec 15, 2010 at 4:26 AM, Russ Abbott <[email protected]> wrote:

> Isn't "Either" the same thing as AorB in
>
> data AorB = Aconstructor Int | Bconstructor Int
>
>
> I want two separate types A and B along with a third type which is their
> Union. Is that not possible?
>
> In my actual case, I have more than two types.  So I would like a way to
> take the union of an arbitrarily number of types.
>
> data Union = A1 | A2 | ...
>
>
> where each of A1, A2, ... has its own data declaration.
> *
> -- Russ *
>
>
> On Tue, Dec 14, 2010 at 12:14 PM, Tobias Brandt <[email protected]
> > wrote:
>
>> data AorB = Aconstructor Int | Bconstructor Int
>
>
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20101215/031eeb0b/attachment-0001.htm>

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

Message: 2
Date: Wed, 15 Dec 2010 14:20:41 +0000
From: Thomas Davie <[email protected]>
Subject: Re: [Haskell-beginners] Type unions
To: Guofeng Zhang <[email protected]>
Cc: beginners <[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii


On 15 Dec 2010, at 14:15, Guofeng Zhang wrote:

> What does "$" mean in Left $ A x. Why does not write it as "Left A x"?
> 
> For putStrLn $ "welcome", is the "$" has the same meaning as that in Left $ A 
> x?

It's an infix operator that does nothing but applies the thing on the left to 
the thing on the right.

The reason it's needed is because Left A x would be parsed as (Left applied to 
A) applied to x, wheras what we want is Left applied to (A applied to x).

This can also be done with parentheses, but is often nicer done with $.

Bob




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

Message: 3
Date: Wed, 15 Dec 2010 08:24:48 -0600
From: aditya siram <[email protected]>
Subject: Re: [Haskell-beginners] Type unions
To: Guofeng Zhang <[email protected]>
Cc: beginners <[email protected]>
Message-ID:
        <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1

'$' has the same effect as parens around whatever's after it so 'Left
$ A x' ==  'Left (A x)'. Since Haskell is left associative 'Left A x'
== '(Left A) x' which is wrong and gives me a compile error.

And yes it has the same effect as putStrLn $ "welcome".

-deech

On Wed, Dec 15, 2010 at 8:15 AM, Guofeng Zhang <[email protected]> wrote:
> What does "$" mean in Left $ A x. Why does not write it as "Left A x"?
> For putStrLn $ "welcome", is the "$" has the same meaning as that in Left $
> A x?
>
> On Wed, Dec 15, 2010 at 4:26 AM, Russ Abbott <[email protected]> wrote:
>>
>> Isn't "Either" the same thing as AorB in
>>
>> data AorB = Aconstructor Int | Bconstructor Int
>>
>> I want two separate types A and B along with a third type which is their
>> Union. Is that not possible?
>> In my actual case, I have more than two types. ?So I would like a way to
>> take the union of an arbitrarily number of types.
>>
>> data Union = A1 | A2 | ...
>>
>> where each of A1, A2, ... has its own data declaration.
>>
>> -- Russ
>>
>> On Tue, Dec 14, 2010 at 12:14 PM, Tobias Brandt
>> <[email protected]> wrote:
>>>
>>> data AorB = Aconstructor Int | Bconstructor Int
>>
>> _______________________________________________
>> Beginners mailing list
>> [email protected]
>> http://www.haskell.org/mailman/listinfo/beginners
>>
>
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>
>



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

Message: 4
Date: Wed, 15 Dec 2010 15:33:39 +0100
From: jean verdier <[email protected]>
Subject: [Haskell-beginners] haven
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset="UTF-8"

I was reading 

http://www.haskell.org/haskellwiki/Applications_and_libraries/Graphics

and i'm interested in haven but the link is dead:
http://haskell.org/haven/

Can someone give me some some pointer ?





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

Message: 5
Date: Wed, 15 Dec 2010 15:37:39 +0100
From: Daniel Fischer <[email protected]>
Subject: Re: [Haskell-beginners] Type unions
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain;  charset="utf-8"

On Wednesday 15 December 2010 15:15:16, Guofeng Zhang wrote:
> What does "$" mean in Left $ A x. Why does not write it as "Left A x"?
>

($) is used for fixity, it's a low-precedence identity for functions. You 
could also use parentheses for that.

"Left $ A x" is equivalent to "Left (A x)" while "Left A x" would be parsed 
as "(Left A) x" - and therefore give a type error, since "Left A" has the 
type Either (Int -> A) b (assuming A is a value constructor for the type A 
which takes an Int argument) and not a function type, hence you can't apply 
it to the value x.

> For putStrLn $ "welcome", is the "$" has the same meaning as that in
> Left $ A x?
>

In `putStrLn $ "welcome"', the $ is completely superfluous because you 
apply putStrLn to an atomic value (syntacically atomic, it's a single 
token), so you can say it has no meaning at all there, or it has the same 
meaning, implicitly adding parentheses, sort of.
If you had `putStrLn $ "Welcome, " ++ name', it would again serve the same 
purpose, to group the tokens to yield a syntactically correct expression.



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

Message: 6
Date: Wed, 15 Dec 2010 15:49:29 +0100
From: Daniel Fischer <[email protected]>
Subject: Re: [Haskell-beginners] haven
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain;  charset="iso-8859-1"

On Wednesday 15 December 2010 15:33:39, jean verdier wrote:
> I was reading
>
> http://www.haskell.org/haskellwiki/Applications_and_libraries/Graphics
>
> and i'm interested in haven but the link is dead:
> http://haskell.org/haven/
>
> Can someone give me some some pointer ?
>

Probably another casualty of the server migration. You can try 
http://haskell.cs.yale.edu/haven/
(the old machine, but I couldn't connect, so I wouldn't be too optimistic).




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

Message: 7
Date: Wed, 15 Dec 2010 15:43:07 +0000
From: Stephen Tetley <[email protected]>
Subject: Re: [Haskell-beginners] haven
Cc: [email protected]
Message-ID:
        <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1

On 15 December 2010 14:49, Daniel Fischer
<[email protected]> wrote:

> Probably another casualty of the server migration. You can try
> http://haskell.cs.yale.edu/haven/
> (the old machine, but I couldn't connect, so I wouldn't be too optimistic).

Also Haven used a bridge to Java for the underlying graphic drawing. I
suspect the JVM-bridge has bit-rotted quite a bit.



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

Message: 8
Date: Wed, 15 Dec 2010 22:37:02 +0100
From: Tim Baumgartner <[email protected]>
Subject: [Haskell-beginners] mapping over newtypes
To: [email protected]
Message-ID:
        <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1

Hello Haskellers,

I defined

newtype Banana = Banana Something

When I work with it, I sometimes use a function

mapBanana f (Banana b) = Banana (f b)

which is of course discarded by the compiler. Is this usual practice
or are there any better solutions?

Regards
Tim



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

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


End of Beginners Digest, Vol 30, Issue 32
*****************************************

Reply via email to