Re: [Haskell-cafe] ANNOUNCE: Generic Haskell 1.80 (Emerald)

2008-04-14 Thread Thomas van Noort

Pablo Nogueira wrote:

This has certainly been taken into account when comparing approaches to
 generic programming. I quote from page 18/19 from the work you and Bulat


Indeed I was not aware of it. Missed that. Thanks for pointing it out!


 Thus, full reflexivity of an approach is taken into account. This suggests
 constrained types are part of Haskell98. So, I'm a bit confused at the
 moment as well.


After reading the Haskell 98 report more carefully I think constrained
types are part of Haskell98. The syntax for algebraic datatype
declarations given is:

  data cx = T u1 ... uk = K1 t11 ... t1k1 | ...| Kn tn1 ... tnkn

Certainly, they are implemented in a peculiar way, with constraints
associated with value constructors and not the type, perhaps to keep
the class and kinds orthogonal (eg, the BinTree type has * - * kind
instead of Ord - * kind).


You are completely right, constraints are optional for data and newtype 
declarations in Haskell98:


http://www.haskell.org/onlinereport/syntax-iso.html#sect9.5

In addition, GHC supports liberalised type synonyms which allows you to 
define constraints:


http://www.haskell.org/ghc/docs/latest/html/users_guide/data-type-extensions.html#type-synonyms

Seems like the mystery is solved now..



At any rate, this has been discussed before in other threads.
Thanks Thomas for your help
P.


You're welcome,
Thomas

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


Re: [Haskell-cafe] ANNOUNCE: Generic Haskell 1.80 (Emerald)

2008-04-14 Thread Pablo Nogueira
 This has certainly been taken into account when comparing approaches to
  generic programming. I quote from page 18/19 from the work you and Bulat

Indeed I was not aware of it. Missed that. Thanks for pointing it out!

  Thus, full reflexivity of an approach is taken into account. This suggests
  constrained types are part of Haskell98. So, I'm a bit confused at the
  moment as well.

After reading the Haskell 98 report more carefully I think constrained
types are part of Haskell98. The syntax for algebraic datatype
declarations given is:

  data cx = T u1 ... uk = K1 t11 ... t1k1 | ...| Kn tn1 ... tnkn

Certainly, they are implemented in a peculiar way, with constraints
associated with value constructors and not the type, perhaps to keep
the class and kinds orthogonal (eg, the BinTree type has * - * kind
instead of Ord - * kind).

At any rate, this has been discussed before in other threads.
Thanks Thomas for your help
P.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] ANNOUNCE: Generic Haskell 1.80 (Emerald)

2008-04-12 Thread Pablo Nogueira
On 12/04/2008, Thomas van Noort [EMAIL PROTECTED] wrote:

  Generic Haskell includes the following features:

  * type-indexed values -- generic functions that can be
instantiated on all Haskell data types.
   ^^^

I have perused the manual and wonder if parametric types with class
constraints are now supported or are not considered Haskell types. I'm
thinking of types such as

data Ord a = BinTree a = Leaf | Node a (BinTree a) (BinTree a)
data Functor f = GRose f a = GLeaf | GNode a (f(GTree f a))
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] ANNOUNCE: Generic Haskell 1.80 (Emerald)

2008-04-12 Thread Miguel Mitrofanov

Generic Haskell includes the following features:

* type-indexed values -- generic functions that can be
  instantiated on all Haskell data types.


How come I haven't ever heard about such a thing?!
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] ANNOUNCE: Generic Haskell 1.80 (Emerald)

2008-04-12 Thread Thomas van Noort
That's a good question. Unfortunately, only Haskell98 types are currently
supported by the Generic Haskell compiler.

But at first sight, implementing support for parametric types with class
constraints is not too hard. Class constraints of a parametric type need
to be propagated to its generated structure type.

Regards,
Thomas

 On 12/04/2008, Thomas van Noort [EMAIL PROTECTED] wrote:

  Generic Haskell includes the following features:

  * type-indexed values -- generic functions that can be
instantiated on all Haskell data types.
^^^

 I have perused the manual and wonder if parametric types with class
 constraints are now supported or are not considered Haskell types. I'm
 thinking of types such as

 data Ord a = BinTree a = Leaf | Node a (BinTree a) (BinTree a)
 data Functor f = GRose f a = GLeaf | GNode a (f(GTree f a))


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


Re: [Haskell-cafe] ANNOUNCE: Generic Haskell 1.80 (Emerald)

2008-04-12 Thread Pablo Nogueira
On 12/04/2008, Thomas van Noort [EMAIL PROTECTED] wrote:

 That's a good question. Unfortunately, only Haskell98 types are currently
  supported by the Generic Haskell compiler.

I thought constrained types were Haskell 98, but now I'm in doubt...

  But at first sight, implementing support for parametric types with class
  constraints is not too hard. Class constraints of a parametric type need
  to be propagated to its generated structure type.

Certainly, but there are a few difficulties for higher-kinded types.
An arguable solution: http://portal.acm.org/citation.cfm?id=1159868

The reason I mention this is because Scrap your Boilerplate supports
them whereas GH does not, and I'm not aware this has been taken into
account when comparing these two approaches in the work cited by Bulat
on this thread.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] ANNOUNCE: Generic Haskell 1.80 (Emerald)

2008-04-12 Thread Thomas van Noort
 On 12/04/2008, Thomas van Noort [EMAIL PROTECTED] wrote:

 That's a good question. Unfortunately, only Haskell98 types are
 currently
  supported by the Generic Haskell compiler.

 I thought constrained types were Haskell 98, but now I'm in doubt...

I'm not 100% sure either, but according to the Haskell98 language report,
constrained types are not part of Haskell98,

http://haskell.org/onlinereport/basic.html ,

but are described as GHC language features,

http://www.haskell.org/ghc/docs/latest/html/users_guide/data-type-extensions.html


  But at first sight, implementing support for parametric types with
 class
  constraints is not too hard. Class constraints of a parametric type
 need
  to be propagated to its generated structure type.

 Certainly, but there are a few difficulties for higher-kinded types.
 An arguable solution: http://portal.acm.org/citation.cfm?id=1159868

 The reason I mention this is because Scrap your Boilerplate supports
 them whereas GH does not, and I'm not aware this has been taken into
 account when comparing these two approaches in the work cited by Bulat
 on this thread.


This has certainly been taken into account when comparing approaches to
generic programming. I quote from page 18/19 from the work you and Bulat
cited:

==
Full reflexivity. A generic programming language is fully reflexive if a
generic function can be used on any type that is definable in the
language. Generic Haskell is fully reflexive with respect to the types
that are definable in Haskell 98, except for constraints in data-type
definitions. So a data type of the form

data Eq a = Set a = NilSet | ConsSet a (Set a)

is not dealt with correctly. However, constrained data types are a corner
case in Haskell and can easily be simulated using other means.
Furthermore, Nogueira [69] shows how to make Generic Haskell work for data
types with constraints.
==

Thus, full reflexivity of an approach is taken into account. This suggests
constrained types are part of Haskell98. So, I'm a bit confused at the
moment as well.

Regards,
Thomas

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


Re: [Haskell-cafe] ANNOUNCE: Generic Haskell 1.80 (Emerald)

2008-04-12 Thread Brandon S. Allbery KF8NH


On Apr 12, 2008, at 13:33 , Thomas van Noort wrote:

On 12/04/2008, Thomas van Noort [EMAIL PROTECTED] wrote:


That's a good question. Unfortunately, only Haskell98 types are
currently
 supported by the Generic Haskell compiler.


I thought constrained types were Haskell 98, but now I'm in doubt...


language. Generic Haskell is fully reflexive with respect to the types
that are definable in Haskell 98, except for constraints in data-type
definitions. So a data type of the form

data Eq a = Set a = NilSet | ConsSet a (Set a)

is not dealt with correctly. However, constrained data types are a  
corner

case in Haskell and can easily be simulated using other means.


I was under the impression corner case here means that H98 lets you  
write it but doesn't handle it very sanely (a GHC-specific extension  
being needed to achieve that).


--
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] [EMAIL PROTECTED]
system administrator [openafs,heimdal,too many hats] [EMAIL PROTECTED]
electrical and computer engineering, carnegie mellon universityKF8NH


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