Re: [GHC] #864: -fgenerics bug

2006-08-15 Thread GHC
#864: -fgenerics bug
---+
  Reporter:  guest |  Owner: 
  Type:  bug   | Status:  closed 
  Priority:  normal|  Milestone: 
 Component:  Compiler  |Version:  6.4.2  
  Severity:  normal| Resolution:  fixed  
  Keywords:| Os:  MacOS X
Difficulty:  Unknown   |   Architecture:  powerpc
---+
Changes (by simonpj):

  * resolution:  = fixed
  * status:  new = closed

Comment:

 Good point.  The derivable-type-class mechanism isn't capable of handling
 higher-rank method types, I'm afraid.  (And much else besides!)  Sorry.

 I've fixed the compiler so that it fails more gracefully; crashing is
 definitely a bug.

 Thanks for pointing this out.

 Test is tcfail163.hs

 Simon

-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/864
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


[GHC] #866: Building unregistarized version

2006-08-15 Thread GHC
#866: Building unregistarized version
-+--
Reporter:  kyukhin   |Owner:   
Type:  bug   |   Status:  new  
Priority:  high  |Milestone:   
   Component:  Build System  |  Version:  6.4  
Severity:  major | Keywords:  unregisterize
  Os:  Linux |   Difficulty:  Easy (1 hr)  
Architecture:  x86   |  
-+--
Hi, all!
 I am trying to create unregisterized build of GHC 6.4.
 In distrib/cross-port I changed path and execute this script.

 After prints
 ==fptools== make all -wr;
  in /home/kyukhin/work/ghx-6.4/ghc/compiler

 builds says nothing at all (I'm wat for two weeks )) )
 System: Ubuntu Dapper Drake
 make - 3.81beta4

 Also I tryed to do it on some other machines ( Xeon servers if Red Hat
 Enterprise).
 And got the same result.

 Can you explain, is it a bug, or my mistake?

 Best Regards, Yukhin Kirill ([EMAIL PROTECTED])

-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/866
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


[GHC] #867: Integer arithmetic gives the wrong answer on amd64/Linux

2006-08-15 Thread GHC
#867: Integer arithmetic gives the wrong answer on amd64/Linux
---+
Reporter:  igloo   |Owner: 
Type:  bug |   Status:  new
Priority:  normal  |Milestone: 
   Component:  Compiler|  Version:  6.4.1  
Severity:  normal  | Keywords: 
  Os:  Linux   |   Difficulty:  Unknown
Architecture:  x86_64 (amd64)  |  
---+
On x86 I get:

 {{{
 Prelude reverse $ take 10 $ reverse $ show $ sum [ x ^ x | x - [1..1000]
 ]
 9110846700
 }}}

 which is correct, but on amd64/Linux I get:

 {{{
 Prelude reverse $ take 10 $ reverse $ show $ sum [ x ^ x | x - [1..1000]
 ]
 0612504812
 }}}

 Both ghci's above are 6.4.1, but I also see it with the HEAD (a few days
 old).

 Seen on Debian, Gentoo and rpath distributions.


 Thanks
 Ian

-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/867
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


Re: [GHC] #867: Integer arithmetic gives the wrong answer on amd64/Linux

2006-08-15 Thread GHC
#867: Integer arithmetic gives the wrong answer on amd64/Linux
---+
  Reporter:  igloo |  Owner:
  Type:  bug   | Status:  new   
  Priority:  normal|  Milestone:
 Component:  Compiler  |Version:  6.4.1 
  Severity:  normal| Resolution:
  Keywords:| Os:  Linux 
Difficulty:  Unknown   |   Architecture:  x86_64 (amd64)
---+
Comment (by duncan):

 I get the same results with ghc-6.4.2 and ghc-6.5.20060724 on my amd64
 box.

 It's fine in hugs on the amd64 and fine with ghc-6.4.2 on my sparc box. On
 both boxes I'm using gmp-4.1.4 (gentoo revision 3).

-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/867
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


RE: recursive import

2006-08-15 Thread Simon Peyton-Jones
Well I agree it's not ideal.  But from what you say it's working as
advertised.

It's not easy to derive hs-boot from hs, because you probably don't want
to put all the type sigs in the hs file into the hs-boot file, because
that might create yet more dependencies for the hs-boot file.  Also a
common thing is to put a data type decl into the hs-boot file without
constructors, and there's not automatic way to decide whether to do
that.

Simon


| -Original Message-
| From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]
| On Behalf Of Serge D. Mechveliani
| Sent: 12 August 2006 16:25
| To: glasgow-haskell-users@haskell.org
| Subject: recursive import
| 
| Please, discard my previous request for the help with  .hs-boot.
| 
| I seem to get through the .hs-boot matter.
| We shall see further.
| 
| Still it looks strange.
| The compiler reports errors: this and this thing must not be in
| .hs-boot.
| As it understands everything, it could take the .hs copy and filter
| what is needed for .hs-boot.
| Why the user needs to create .hs-boot by hand?
| 
| -
| Serge Mechveliani
| [EMAIL PROTECTED]
| 
| ___
| Glasgow-haskell-users mailing list
| Glasgow-haskell-users@haskell.org
| http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


RE: class declaration in boot file

2006-08-15 Thread Simon Peyton-Jones
You can't use 'deriving' in hs-boot files, nor instance declarations.

In the HEAD (and hence in 6.6) you can put instance declarations in
though, thus:

data DT2
instance Show DT2

Simon

| -Original Message-
| From: Gaal Yahas [mailto:[EMAIL PROTECTED]
| Sent: 11 August 2006 21:06
| To: Simon Peyton-Jones
| Cc: GHC Users Mailing List
| Subject: Re: class declaration in boot file
| 
| (I forgot to say, this was with 6.4.2.)
| 
| Another problem I'm having is that when I consume a datatype, its
| derived instances aren't available; and even in an hs-boot file, a
| 'deriving' clause is illegal on a type with no constructors. So I
can't
| compile B in this case:
| 
| module A where
| 
| import B
| data DT1 = X | Y deriving Show
| 
| module B where
| 
| import {-# SOURCE #-} A
| 
| data DT2 = MkDT2 { Q :: DT1 } deriving Show
| 
| Because of missing Show instances for DT1. (In practise, I think it
| might work if I spell out the full declaration of DT1 with the
deriving
| clause, but I don't want the creep: X and Y are really records
entailing
| additional types B need not concern itself with.)
| 
| I'm hoping 6.6 will allow me to say this in the hs-boot file:
| 
| data DT1 deriving Show
| 
| On Fri, Aug 11, 2006 at 10:59:29AM +0100, Simon Peyton-Jones wrote:
|  Well this is odd.  The manual (for 6.6 anyway) says that class decls
are
|  allowed in hs-boot files, but instance decls are not, whereas the
code
|  seems to say that class decls aren't but instance decls are!
| 
|  I will look into this.  Meanwhile, I'm afraid you just can't put a
class
|  decl in the hs-boot file with the version of the compiler you have.
| 
|  Simon
| 
|  | -Original Message-
|  | From: [EMAIL PROTECTED]
|  [mailto:[EMAIL PROTECTED]
|  | On Behalf Of Gaal Yahas
|  | Sent: 09 August 2006 18:25
|  | To: GHC Users Mailing List
|  | Subject: class declaration in boot file
|  |
|  | I'm trying to solve a circularity problem with .hs-boot, but am
|  getting
|  | the error: Illegal class declaration in hs-boot file.
|  |
|  | The offending declaration is:
|  |
|  | class (Monad m, Functor m, Eq a, Data a, Typeable a) = ICoercible
m a
|  | a - m
|  |
|  | I've tried with and without the fundeps. Data and Typeable are in
|  scope,
|  | and -fglasgow-exts is set. Any ideas on what else I should be
doing?
|  |
|  | --
|  | Gaal Yahas [EMAIL PROTECTED]
|  | http://gaal.livejournal.com/
|  | ___
|  | Glasgow-haskell-users mailing list
|  | Glasgow-haskell-users@haskell.org
|  | http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
| 
| --
| Gaal Yahas [EMAIL PROTECTED]
| http://gaal.livejournal.com/
___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


RE: class declaration in boot file

2006-08-15 Thread Simon Peyton-Jones
Prodded by your mail, I've gotten back to hs-boot files.  I've fixed the
HEAD so that both class and instance declarations are allowed in hs-boot
files. But not 'deriving'!

Simon

| -Original Message-
| From: Gaal Yahas [mailto:[EMAIL PROTECTED]
| Sent: 11 August 2006 21:06
| To: Simon Peyton-Jones
| Cc: GHC Users Mailing List
| Subject: Re: class declaration in boot file
| 
| (I forgot to say, this was with 6.4.2.)
| 
| Another problem I'm having is that when I consume a datatype, its
| derived instances aren't available; and even in an hs-boot file, a
| 'deriving' clause is illegal on a type with no constructors. So I
can't
| compile B in this case:
| 
| module A where
| 
| import B
| data DT1 = X | Y deriving Show
| 
| module B where
| 
| import {-# SOURCE #-} A
| 
| data DT2 = MkDT2 { Q :: DT1 } deriving Show
| 
| Because of missing Show instances for DT1. (In practise, I think it
| might work if I spell out the full declaration of DT1 with the
deriving
| clause, but I don't want the creep: X and Y are really records
entailing
| additional types B need not concern itself with.)
| 
| I'm hoping 6.6 will allow me to say this in the hs-boot file:
| 
| data DT1 deriving Show
| 
| On Fri, Aug 11, 2006 at 10:59:29AM +0100, Simon Peyton-Jones wrote:
|  Well this is odd.  The manual (for 6.6 anyway) says that class decls
are
|  allowed in hs-boot files, but instance decls are not, whereas the
code
|  seems to say that class decls aren't but instance decls are!
| 
|  I will look into this.  Meanwhile, I'm afraid you just can't put a
class
|  decl in the hs-boot file with the version of the compiler you have.
| 
|  Simon
| 
|  | -Original Message-
|  | From: [EMAIL PROTECTED]
|  [mailto:[EMAIL PROTECTED]
|  | On Behalf Of Gaal Yahas
|  | Sent: 09 August 2006 18:25
|  | To: GHC Users Mailing List
|  | Subject: class declaration in boot file
|  |
|  | I'm trying to solve a circularity problem with .hs-boot, but am
|  getting
|  | the error: Illegal class declaration in hs-boot file.
|  |
|  | The offending declaration is:
|  |
|  | class (Monad m, Functor m, Eq a, Data a, Typeable a) = ICoercible
m a
|  | a - m
|  |
|  | I've tried with and without the fundeps. Data and Typeable are in
|  scope,
|  | and -fglasgow-exts is set. Any ideas on what else I should be
doing?
|  |
|  | --
|  | Gaal Yahas [EMAIL PROTECTED]
|  | http://gaal.livejournal.com/
|  | ___
|  | Glasgow-haskell-users mailing list
|  | Glasgow-haskell-users@haskell.org
|  | http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
| 
| --
| Gaal Yahas [EMAIL PROTECTED]
| http://gaal.livejournal.com/
___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


[Haskell] Call for participation: Workshop on Generic Programming 2006

2006-08-15 Thread Ralf Hinze
Dear all,

the Workshop on Generic Programming early registration deadline is only a
few days away: August 18, 2006 (http://regmaster2.com/conf/icfp2006.html).

== We have reserved 30 minutes for *lightning talks*. If you plan to
== attend and if you would like to give a short talk (about half-baked,
== exciting, new stuff) please drop me a short note. Slots will be
== reserved on a first-come-first-serve basis.

Looking forward to seeing you in Portland, Ralf Hinze



   CALL FOR PARTICIPATION

 Workshop on Generic Programming 2006

Portland, Oregon, 16th September 2006

  The Workshop on Generic Programming is sponsored by ACM SIGPLAN
  and forms part of ICFP 2006. Previous Workshops on Generic
  Programming have been held in Marstrand (affiliated with MPC),
  Ponte de Lima (affiliated with MPC), Nottingham (informal
  workshop), Dagstuhl (IFIP WG2.1 Working Conference), Oxford
  (informal workshop), and Utrecht (informal workshop).

  http://www.informatik.uni-bonn.de/~ralf/wgp2006.{html,pdf,ps,txt}



Preliminary program
---

 9.oo - 1o.3o, session chair: Ralf Hinze (Universität Bonn)
  Welcome

  Design Patterns as Higher-Order Datatype-Generic Programs
  Jeremy Gibbons (Oxford University)

  Type Theoretic Design Patterns
  Ondrej Rypacek, Roland Backhouse, Henrik Nilsson (University of Nottingham)

  Generating Generic Functions
  Johan Jeuring, Alexey Rodriguez, Gideon Smeding (Utrecht University)

11.oo - 12.3o, session chair: Peter Dybjer (Chalmers University of Technology)

  Good Advice for Type-Directed Programming
  Geoffrey Washburn, Stephanie Weirich (University of Pennsylvania)

  Context-Parametric Polykinded Types
  Pablo Nogueira (University of Nottingham)

  Modular Generic Programming with Extensible Superclasses
  Martin Sulzmann, Meng Wang (University of Singapore)

14.3o - 16.oo, session chair: Jeremy Gibbons (Oxford University)
  Report from the program chair
  Ralf Hinze (Universität Bonn)

  Scrap++: Scrap Your Boilerplate in C++
  Gustav Munkby, Andreas Priesnitz, Sibylle Schupp, Marcin Zalewski (Chalmers 
University of Technology)

  A Technique for Generic Iteration and Its Optimization
  Stephen Watt (University of Western Ontario)

  Lightning talks: to be announced

16.3o - 18.oo, session chair: Jeremy Siek (Rice University)

  Towards An Automatic Complexity Analysis for Generic Programs
  Kyle Ross (Indiana University)

  An Object-Oriented Approach to Datatype Generic Programming
  Adriaan Moors, Frank Piessen, Wouter Joosen (Katholieke Universiteit Leuven)

  Discussion



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


Re[2]: map and fmap

2006-08-15 Thread Bulat Ziganshin
Hello Duncan,

Tuesday, August 15, 2006, 2:37:50 AM, you wrote:

 If it goes in that direction it'd be nice to consider the issue of
 structures which cannot support a polymorphic map. Of course such
 specialised containers (eg unboxed arrays or strings) are not functors
 but they are still useful containers with a sensible notion of map.

unboxed arrays - not if you using implementation from ArrayRef lib

ByteStrings - can be also parameterized by its type elements, as i
always suggested. of course, these elements should be unboxable and
belong to the Storable class in order to allow peek/poke them

there is also faking solution:

type ByteStr a = ByteString
instance Functor ByteStr

(although i never tested it)


-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re: Re[6]: All Monads are Functors

2006-08-15 Thread Jon Fairbairn
On 2006-08-15 at 16:25CDT Taral wrote:
 On 8/15/06, Bulat Ziganshin [EMAIL PROTECTED] wrote:
  in this case we lose class Functor a = Monad a base class
  declaration. so what will be the meaning of this:
 
 I don't see why that is the case.
 
 class Functor m = Monad m where
 return :: a - m a
 (=) :: m a - (a - m b) - m b
 instance Functor m where
 fmap f = (= return . f)
 
 What's wrong with this? All Monads are Functors. If you don't provide
 a Functor, it gets defined for you. The problem is working out whether
 to use the default Functor or an external Functor.

It seems obvious to me that we always use an external
definition if one exists, so I suppose the problem is
knowing whether an external instance exists -- so this
proposal would rely on doing something about scoping for
instances, I suppose.

-- 
Jón Fairbairn  Jon.Fairbairn at cl.cam.ac.uk


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


Re: All Monads are Functors

2006-08-15 Thread Marc A. Ziegert
Am Dienstag, 15. August 2006 23:34 schrieb Jon Fairbairn:
 On 2006-08-15 at 16:25CDT Taral wrote:
  On 8/15/06, Bulat Ziganshin [EMAIL PROTECTED] wrote:
   in this case we lose class Functor a = Monad a base class
   declaration. so what will be the meaning of this:
  
  I don't see why that is the case.
  
  class Functor m = Monad m where
  return :: a - m a
  (=) :: m a - (a - m b) - m b
  instance Functor m where
  fmap f = (= return . f)
  
  What's wrong with this? All Monads are Functors. If you don't provide
  a Functor, it gets defined for you. The problem is working out whether
  to use the default Functor or an external Functor.
 
 It seems obvious to me that we always use an external
 definition if one exists, so I suppose the problem is
 knowing whether an external instance exists -- so this
 proposal would rely on doing something about scoping for
 instances, I suppose.
 

I see a solution in different ways of writitng an instance:

[code]

-- to define the functions in the Functor, using the defaults defined in the 
class _Functor_ (assumed there would be any default):
instance Monad m where
  return = ...
  (=) = ...
instance Functor m where

-- to define the functions in the Functor, using the defaults defined in the 
class _Monad_:
instance Monad m where
  return = ...
  (=) = ...
  instance Functor m where

--to define a new Functor:
instance Monad m where
  return = ...
  (=) = ...
  instance Functor m where
fmap = ...
--or
instance Monad m where
  return = ...
  (=) = ...
instance Functor m where
  fmap = ...

[/code]

the advantages are, that we can decide which default functions we want to use, 
and that it will be compatible to the old library.


- marc
___
Haskell-prime mailing list
Haskell-prime@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-prime


Re: [Haskell-cafe] Re: Why Haskell?

2006-08-15 Thread Johan Tibell

While having a single standardised library is a nice goal, I think a
first step would be to highlight the current state and pros and cons
of the various options.

Perhaps we could at least have wiki pages with recommendations?  So
that a potential user of some particular functionality - whether it
is database accesss, GUI, XML, web application development, and so on
- can make an as informed decision as possible?


I think that would be great. I'm not really qualified to speak of the
relative merits of different libraries. Perhaps if someone (I) created
a wiki page and then the respective authors could contribute?
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: map and fmap

2006-08-15 Thread Duncan Coutts
On Tue, 2006-08-15 at 12:38 +0200, John Hughes wrote:

 One thing I've observed repeatedly is that many students in later
 years, who learned functional programming early, have a strong
 impression that functional languages are only suitable for toy
 programs. Of course, that's because in their first courses they only
 SAW toy programs. But perhaps, they also moved on to Java as soon as
 they started to build GUIs, and as a result have the impression that
 you CAN'T build a GUI in the functional language they learned first.

Yes, this was the same impression my colleagues had as undergraduates
and it's the same thing I see in the students I now teach.

 This is a very negative impression for students to have, and one that
 is hard to combat because beginning undergraduates are sceptical to
 functional languages from the word go: they know they really want to
 learn C++ or Java, and wonder initially what we're playing at.
 
 I combat that--successfully--by showing them early on that Haskell
 *is* a real programming language, in which one can build real
 applications. I tell them about darcs, or whatever new application is
 hot at the time. I show them how to build a GUI in wxHaskell--in the
 fifth week of their university studies.

Yay! I'm doing the same thing, the fifth week in their first term in
their first year. Though I'm using Gtk2Hs of course :-)

I don't make them build the GUI directly of course. I've got a practical
where they do some list processing functions and we provide a GUI module
which visualises what they've done. So while still teaching the basics I
try to make it clear that that can do GUIs and do them easily and make
them look attractive.

This year I want to add an optional extension to go 3D, to visualise
their stuff with singing dancing rotatey things. I managed to get the
Gtk2Hs+HOpenGL stuff working by the end of the practical last year and
had lots of students come over to say wow!. So I'm looking forward to
using it this year to motivate the students to do the optional sections
of the practical.

  I want them to be frustrated at how difficult GUI programming is when
 they do it in Java (:-)! It works--some find it very hard, but many of
 the good students go much further than my lectures and exercises, and
 reappear in the third and fourth years as very expert and enthusiastic
 Haskell programmers.

This is the first year when people who did my Haskell GUI practical will
go on to the OOP course which involves building a GUI in Java. I'll be
interested to see how they think it compares.

Duncan

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


Re: [Haskell-cafe] type gurus, can you please help?

2006-08-15 Thread Gabriel Dos Reis
Bulat Ziganshin [EMAIL PROTECTED] writes:

[...]

| Moreover, Haskell type classes supports inheritance. Run-time
| polymorphism together with inheritance are often seen as OOP
| distinctive points, so during long time i considered type classes as a
| form of OOP implementation. but that's wrong! Haskell type classes
| build on different basis, so they are like C++ templates with added
| inheritance and run-time polymorphism! And this means that usage of
| type classes is different from using classes, with its own strong and
| weak points.

Roughly Haskell type classes correspond to parameterized abstract
classes in C++ (i.e. class templates with virtual functions 
representing the operations).  Instance declarations correspond to
derivation and implementations of those parameterized classes.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Nice cygwin application to be used with ghci

2006-08-15 Thread Maurício

  Hi,

  I've just uploaded a package ('rlwrap') to cygwin that I like to use 
with ghci. You can use it like this:


rlwrap ghcii.sh

and then you will use ghci as if it were readline aware (i.e., you can 
press up arrow to get last typed lines etc.). 'rlwrap' is very stable 
and I never had unexpected results while using it.
  Since the issue of ghci integration with terminals has been raised 
here sometimes, I thought some guys here would be interested (actually, 
I found rlwrap looking for a better way to use ghci).


  Best,
  Maurício

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


[Haskell-cafe] Genetic programming Haskell

2006-08-15 Thread Maurício

  Hi,

  Does anyone know of a package for genetic programming for Haskell? I 
tried some links from Haskell wiki and some I found on google, and found 
many interesting papers, but none of them pointed to downloadable code. 
Does anyone know where can I find a good implementation (even an 
experimental one)?


  Thanks,
  Maurício

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


[Haskell-cafe] The Q Programming Language can do symbolic manipulation -- Haskell?

2006-08-15 Thread Casey Hawthorne
The Q Programming Language can do symbolic manipulation -- Haskell?

The Q Programming Language can do the following:

sqr X = X*X

==sqr 5
25

==sqr (X+1) 
(X+1)*(X+1)

Can Haskell do symbolic manipulation?

Or are term-rewriting and the lambda calculus sufficiently far enough
apart concepts?
--
Regards,
Casey
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] The Q Programming Language can do symbolic manipulation -- Haskell?

2006-08-15 Thread Lemmih

On 8/16/06, Casey Hawthorne [EMAIL PROTECTED] wrote:

The Q Programming Language can do symbolic manipulation -- Haskell?

The Q Programming Language can do the following:

sqr X = X*X

==sqr 5
25

==sqr (X+1)
(X+1)*(X+1)

Can Haskell do symbolic manipulation?

Or are term-rewriting and the lambda calculus sufficiently far enough
apart concepts?


You can do (if you don't mind cheating) :

Compiling Sym  ( Sym.hs, interpreted )
:Ok, modules loaded: Sym.
*Sym :!cat Sym.hs
module Sym where

data Sym a = Const a
  | Var String
  | Sym a `Mult` Sym a
  | Sym a `Plus` Sym a
  | Sym a `Minus` Sym a
deriving (Eq,Show)

instance Num a = Num (Sym a) where
   (+) = Plus
   (*) = Mult
   abs = id
   signum = id
   fromInteger = Const . fromInteger

sqr x = x*x

*Sym sqr 5
25
*Sym sqr (Var X + 1)
(Var X Plus Const 1) Mult (Var X Plus Const 1)

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