[Haskell-cafe] Using - as both type and value constructor

2011-08-24 Thread Armando Blancas
Studying the paper *A Simple Implementation for Priority Search Queues*, by
Ralf Hinze, I came across the following syntax that I didn't understand and
I couldn't use in GHCi 7.0.3 for defining a binding data type (page 3):

Bindings are represented by the following data type:
*data k - p = k - p*
key :: (k - p) - k
key (k - p) = k
prio :: (k - p) - p
prio (k - p) = p
Note that we use '-' both as a type constructor and value constructor.
[...] data PSQ k p

The following page has these value constructors:

*0 :: PSQ k p*
*{.} :: (k - p) - PSQ k p*


The paper says that's Haskell '98 code. I'll appreciate info on what kind of
data declaration those are and any pointers to related documentation. Or
maybe those are deprecated features. I'm stuck in this part.

-armando

www.cs.ox.ac.uk/people/ralf.hinze/talks/ICFP01.pdf
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Using - as both type and value constructor

2011-08-24 Thread Daniel Fischer
On Wednesday 24 August 2011, 20:24:14, Armando Blancas wrote:
 Studying the paper *A Simple Implementation for Priority Search Queues*,
 by Ralf Hinze, I came across the following syntax that I didn't
 understand and I couldn't use in GHCi 7.0.3 for defining a binding data
 type (page 3):
 
 Bindings are represented by the following data type:
 *data k - p = k - p*
 key :: (k - p) - k
 key (k - p) = k
 prio :: (k - p) - p
 prio (k - p) = p
 Note that we use '-' both as a type constructor and value constructor.
 [...] data PSQ k p
 
 The following page has these value constructors:
 
 *0 :: PSQ k p*
 *{.} :: (k - p) - PSQ k p*
 
 
 The paper says that's Haskell '98 code.

I didn't see that claim in the linked slides, and it's not Haskell '98 (nor 
Haskell 2010).
There's a translation of the principles to Haskell from page 17 on or so.

 I'll appreciate info on what
 kind of data declaration those are and any pointers to related
 documentation. Or maybe those are deprecated features.

I don't think the notation from the beginning ever was legal Haskell, I 
think it was chosen to present the ideas separated from syntax.

 I'm stuck in this part.
 
 -armando
 
 www.cs.ox.ac.uk/people/ralf.hinze/talks/ICFP01.pdf


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Using - as both type and value constructor

2011-08-24 Thread Armando Blancas

  I didn't see that claim in the linked slides, and it's not Haskell '98
 (nor
  Haskell 2010).


I didn't realize it linked to the slides; I thought that pointed to the
article. I just found another version of the paper, A Simple Implementation
Technique for Priority Search Queues, by Hinze, which shows the binding type
as a pair, with access functions for k and p. I'll continue to work my way
through the material there. Thanks for you response.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Using - as both type and value constructor

2011-08-24 Thread wren ng thornton

On 8/24/11 5:03 PM, Armando Blancas wrote:



I didn't see that claim in the linked slides, and it's not Haskell '98

(nor Haskell 2010).


I didn't realize it linked to the slides; I thought that pointed to the
article. I just found another version of the paper, A Simple Implementation
Technique for Priority Search Queues, by Hinze, which shows the binding type
as a pair, with access functions for k and p. I'll continue to work my way
through the material there. Thanks for you response.


With -XTypeOperators you can define

data a :- b = a :- b

where (:-) is both a type constructor and a data constructor. Note the 
leading colon which is the only capital punctuation letter. Hinze may 
have just chosen to elide the colon for prettiness.


--
Live well,
~wren

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Using - as both type and value constructor

2011-08-24 Thread Armando Blancas
Thanks for the info; that's good to know. The ICFP '01 version uses pairs;
not sure when the other came out or where.

On Wed, Aug 24, 2011 at 4:46 PM, wren ng thornton w...@freegeek.org wrote:

 On 8/24/11 5:03 PM, Armando Blancas wrote:


  I didn't see that claim in the linked slides, and it's not Haskell '98

 (nor Haskell 2010).


 I didn't realize it linked to the slides; I thought that pointed to the
 article. I just found another version of the paper, A Simple
 Implementation
 Technique for Priority Search Queues, by Hinze, which shows the binding
 type
 as a pair, with access functions for k and p. I'll continue to work my way
 through the material there. Thanks for you response.


 With -XTypeOperators you can define

data a :- b = a :- b

 where (:-) is both a type constructor and a data constructor. Note the
 leading colon which is the only capital punctuation letter. Hinze may have
 just chosen to elide the colon for prettiness.

 --
 Live well,
 ~wren

 __**_
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/**mailman/listinfo/haskell-cafehttp://www.haskell.org/mailman/listinfo/haskell-cafe

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe