Arka al Eel | 1 Jul 12:06 2005
Picon

best way to do generic programming?

Hi,

I'm playing with generic programming. At the moment I'm interested in
reusable transformations on data types. Provided for example a toy
datatype Expr like this:

data Expr = Const Int | Var String | Add Expr Expr

Plus a function "optimize" that optimizes a pattern "x + 0" into "x":

optimize (Add x (Const 0)) = x

You would now want this to be this generic, so the function should be
recursive for all other constructors *and* other data types. For
example, suppose that Expr is included in other datatype:

data Stm = Assign String Expr | Seq Stm Stm

I now want the "optimize" transformation to work on Stm, like
this:

x = optimize (Seq (Assign (Add (Var "x") (Const 0))) blah blah)

For sure, I don't want to write specific code for type Stm. The thing
I want is to generically walk through values of those types into Expr
where it can apply the pattern.

Haskell does not seem to have an easy way to do this.  After looking
through some papers I found lots of things that *might* handle this,
like Generic Haskell, "scrap your boilerplate", Drift, etc. Now I'm
(Continue reading)

Mirko Rahn | 1 Jul 12:42 2005
Picon

Re: best way to do generic programming?


> data Expr = Const Int | Var String | Add Expr Expr

> optimize (Add x (Const 0)) = x

> You would now want this to be this generic, so the function should be
> recursive for all other constructors *and* other data types. For
> example, suppose that Expr is included in other datatype:

> data Stm = Assign String Expr | Seq Stm Stm
> 
> I now want the "optimize" transformation to work on Stm, like
> this:

> x = optimize (Seq (Assign (Add (Var "x") (Const 0))) blah blah)

> For sure, I don't want to write specific code for type Stm. The thing
> I want is to generically walk through values of those types into Expr
> where it can apply the pattern.

A one minute solution using the "Scrap your boilerplate" approach is:

{-# OPTIONS -fglasgow-exts #-}

import Data.Generics

data Expr = Const Int
	  | Var String
	  | Add Expr Expr
	    deriving ( Data , Typeable , Show )
(Continue reading)

johanj | 1 Jul 13:36 2005
Picon

Re: best way to do generic programming?

Here is a solution to your problem in Generic Haskell, see
www.generic-haskell.org.

You use gmap to traverse the structure, and
have a special case for the type Expr, which does the
optimization.

I'm surprised the `real world' is this easy :-)

---------------------------------------------
module Optimize where

import GH.Library.Map

data Expr = Const Int | Var String | Add Expr Expr deriving Show

data Stm = Assign String Expr | Seq Stm Stm deriving Show

stmt :: Stm
stmt = Seq (Assign "y" (Add (Var "x") (Const 0)))
           (Assign "z" (Add (Const 0) (Var "y")))

optimize {| t :: * |} :: (optimize{|t|}) => t -> t
optimize extends gmap
optimize {|Expr|} e =
  case e of
    Add x (Const 0) -> x
    Add (Const 0) x -> x
    e'              -> e'

(Continue reading)

Malcolm Wallace | 1 Jul 14:06 2005
Picon

Re: best way to do generic programming?

Arka al Eel <arkaaleel <at> gmail.com> writes:

> Haskell does not seem to have an easy way to do this.  After looking
> through some papers I found lots of things that *might* handle this,
> like Generic Haskell, "scrap your boilerplate", Drift, etc. Now I'm
> not sure what works best for real world, bread and butter programming.

You might find this interesting:

    TypeCase: A Design Pattern for Type-Indexed Functions
    http://lambda-the-ultimate.org/node/view/786

It compares a couple of ways of achieving generic programming.

Regards,
    Malcolm
PLANET | 1 Jul 11:55 2005
Picon

Research positions in AI


        [Apologies if you receive multiple copies]

---------------------------------------------
RESEARCH POSITIONS IN ARTIFICIAL INTELLIGENCE
---------------------------------------------

National ICT Australia (NICTA) is seeking applications from high
performing researchers to work in its Knowledge Representation and
Reasoning (KRR) Program. The positions are based at the Canberra
laboratories of NICTA located at the Australian National University.

Appointments may be at the following levels:

o principal researcher, continuing, salary package: 100-150K AUD
o senior researcher, 3 years initially, salary package: 85-130K AUD
o researcher, 3 years initially, salary package: 70-100K AUD

Candidates should have a PhD in computer science or a related field,
and a record of achievements in one or more of the following areas:

o Planning & scheduling
o Model-based diagnosis
o Model-checking in AI
o Reinforcement learning
o Constraints and search

Current members of the group include:

o Anbulagan
(Continue reading)

Dariusz Biernacki | 1 Jul 21:36 2005
Picon
Picon

ICFP 2005 - Call for Participation

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

                      CALL FOR PARTICIPATION

           The 10th ACM SIGPLAN International Conference 
	       on Functional Programming (ICFP 2005) 

                        Tallinn, Estonia

       		     September 26-28, 2005

               http://www.brics.dk/~danvy/icfp05/

            Co-located with TFP 2005 (September 23-24) 
             and GPCE 2005 (September 29 - October 1)

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

ICFP 2005 provides a forum for researchers and developers to hear
about the latest work on the design, implementations, principles, 
and uses of functional programming. The conference covers the entire 
spectrum of work, from practice to theory, including its peripheries.

Conference Organizers:

  General Chair: 
    Olivier Danvy, BRICS, University of Aarhus

  Program Chair: 
    Benjamin Pierce, University of Pennsylvania
(Continue reading)

Kevin Hammond | 4 Jul 14:30 2005
Picon
Picon

[ANNOUNCEMENT]: TFP '05: Third & Final Call for Papers

[With apologies in advance for any duplication.  Kevin]

THIRD & FINAL CALL FOR PAPERS
TFP 2005 <http://www.tifp.org/tfp05>: Sixth 
Symposium on Trends in Functional Programming,

September 23rd-24th 2005, Tallinn, Estonia 
(co-located with ICFP 2005 and GPCE 2005).

Deadline for submission of extended abstracts:	Weds  13th July 2005
(Please note the extended deadline)

The 2005 Symposium on Trends in Functional 
Programming (TFP '05) is an international forum
for researchers with interests in all aspects of 
functional programming languages, focusing
on providing a broad view of current and future 
trends in Functional Programming.
Previous TFP symposia were held in Munich, 
Germany in 2004, in Scotland in 2002 and 2003,
as successors to the successful series of 
Scottish Functional Programming Workshops.

TFP <http://www.tifp.org/> aims to combine a 
lively environment for presenting the latest
research results with  a formal post-symposium 
refereeing process leading to the
publication by Intellect of a high-profile volume 
containing a selection of the best papers
presented at the symposium. A review of a 
(Continue reading)

Donald Bruce Stewart | 6 Jul 08:09 2005
Picon
Picon

ANNOUNCE: hs-plugins 0.9.10


hs-plugins 0.9.10 has been released.

hs-plugins is a dynamic loader and runtime compilation library for Haskell. 
Highlights of this release include:
    * support for GHC 6.4, and cabalised packages
    * ported to Windows of various flavours thanks to Vivian McPhail and Shelarcy
    * now uses HSX parser, thanks to Niklas Broberg
    * extended load interface, thanks to Lemmih
    * source now in a darcs repository
    * supports building with GNU make -jN
    * Simplified module hierarchy, moved under System.* namespace

You can find the code at:
     http://www.cse.unsw.edu.au/~dons/hs-plugins

Cheers,
     Don Stewart
Andrew Butterfield | 6 Jul 15:51 2005
Picon
Picon

IFL'05 - 2nd Call for Papers (new: Accomodation/Registration details)


Apologies, as ever, for multiple copies....

= Call for Papers/Participation =

Announcement and Call for Papers for the 17th International Workshop
on the Implementation and Application of Functional Languages (IFL'05)

September 19th-21st, 2005, Dublin, Ireland.
Website: http://www.cs.tcd.ie/ifl05
E-mail: ifl05 <at> cs.tcd.ie

== Scope and Topics ==

The IFL workshops form a tradition that has lasted for nearly two
decades. The aim of these workshops is to bring together
researchers actively engaged in the implementation and application
of functional and function-based programming languages. They
provide an open forum for researchers who wish to present and
discuss new ideas and concepts, work in progress, preliminary
results, etc. related primarily but not exclusively to the
implementation and application of functional languages.

Topics of interest include, but are not limited to
  * language concepts
  * type checking
  * compilation techniques
  * generic programming techniques
  * (abstract) interpretation
  * automatic program generation
(Continue reading)

James Lipton | 6 Jul 15:06 2005

Final Call for papers: MoveLog05 (ICLP workshop)

[The Types Forum, http://lists.seas.upenn.edu/mailman/listinfo/types-list]

*************** APOLOGIES FOR MULTIPLE POSTING **************

        **** FINAL CALL FOR PAPERS: JULY 10 DEADLINE ****

                           MoVeLog'05

         Mobile Code Safety and Program Verification
               Using Computational Logic Tools

        An ICLP Workshop, Sitges, Spain, Oct. 5, 2005

              http://babel.ls.fi.upm.es/movelog05

Computational logic and logic programming in particular can support
rich reasoning about programs, proofs, types, and specifications.

Recent breakthroughs in mobile code safety and program verification
have brought even more relevance to these tools, especially in the
areas of meta-logic proof theory, proof search, static analysis and
abstract interpretation, and model checking, even when the object code
involved is very far from declarative. Components are needed that can
perform such reasoning and the logic programming community is well
positioned to provide such components.

Especially promising has been ground-breaking work with proof-
carrying-code, a development that shows signs of having widespread
applications, and has brought a surprising number of new challenges
where computational logic can potentially contribute. It is worth
(Continue reading)


Gmane