ANNOUNCE: Generic Haskell 1.80 (Emerald)

Generic Haskell version 1.80 (Emerald) ====================================== We are happy to announce the fifth release of Generic Haskell, an extension of Haskell that facilitates generic programming. Generic Haskell includes the following features: * type-indexed values -- generic functions that can be instantiated on all Haskell data types. * type-indexed types -- types which are indexed over the type constructors underlying Haskell datatypes. The Generic Haskell compiler takes Generic Haskell source and produces Haskell code. Changes since 1.62 (Diamond) ---------------------------- * Generic views for generic types [1] are now supported. * The implementation of type-indexed types is improved. Download -------- The Generic Haskell compiler is available in source and binary distributions. Binaries for Linux, Windows, and MacOSX are available. These are available from: http://www.generic-haskell.org/compiler.html The documentation is also available separately from that page. For more general information, point your browser to: http://www.generic-haskell.org Why Generic Haskell? -------------------- Software development often consists of designing datatypes, around which functionality is added. Some functionality is datatype specific, whereas other functionality is defined on almost all datatypes in such a way that it depends only on the structure of the datatype. A function that works on many datatypes in this way is called a generic function. Examples of generic functionality include editing, pretty-printing or storing a value in a database, and comparing two values for equality. Since datatypes often change and new datatypes are introduced, we have developed Generic Haskell, an extension of the functional programming language Haskell that supports generic definitions, to save the programmer from (re)writing instances of generic functions. The original design of Generic Haskell is based on work by Ralf Hinze. Pleasant programming, The Generic Haskell Team at Utrecht University info@generic-haskell.org [1] Thomas van Noort. Generic views for generic types. Master's thesis, Utrecht University, 2008.

On 12/04/2008, Thomas van Noort
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))

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
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))

On 12/04/2008, Thomas van Noort
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.

On 12/04/2008, Thomas van Noort
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...
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

On Apr 12, 2008, at 13:33 , Thomas van Noort wrote:
On 12/04/2008, Thomas van Noort
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] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH

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.

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... 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

Hello Miguel, Saturday, April 12, 2008, 5:54:45 PM, you wrote:
How come I haven't ever heard about such a thing?!
it's an overview of generic haskell programming systems: http://dfa.imn.htwk-leipzig.de/~waldmann/draft/meta-haskell/second.pdf ask here about final version of this paper -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com

Hello Bulat, Saturday, April 12, 2008, 6:10:04 PM, you wrote:
it's an overview of generic haskell programming systems:
found longer paper myself: Comparing Approaches to Generic Programming in Haskell http://www.cs.uu.nl/~johanj/publications/ComparingGP.pdf -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com
participants (5)
-
Brandon S. Allbery KF8NH
-
Bulat Ziganshin
-
Miguel Mitrofanov
-
Pablo Nogueira
-
Thomas van Noort