[Haskell-cafe] Haskell versus Lisp

2005-09-16 Thread Mark Carter

This is not a troll, honest, so please bear with me ...

I'm a C/C++/VBA programmer (although the former 2 are several years old 
for me), with a sprinkling of Python. Needless to say, I was looking to 
see if there were any better ways of doing things. I've given things 
like Ruby and Scheme a bit of peck, and failed to get particularly 
enthusiastic about them. Two very interesting choices, though, appear to 
be Lisp and Haskell. It struck me that Lisp was, perhaps, the Ultimate 
Programming Language, the One True Language to rule them all; except 
that I always kept  abandoning it for one reason or another (fiddly 
installation, lack of libraries, compatability problems,  cost, possible 
license issues, etc.). My current foray in Haskell seems encouraging. 
wxHaskell installed a breeze, and seems quite usable (even though I'm a 
raw n00b to the language, and admittedly haven't grokked the semantics, 
and all this  cid:part1.01000702.09000407@yahoo.co.uk IO a - IO () 
business). On the one hand, it  seems kinda academic, but on the other, 
it looks like it wants to be practical, too.


Bearing this in mind, and hoping you can see where I'm coming from, I 
think my question is: shouldn't you guys be using Lisp?



___ 
To help you stay safe and secure online, we've developed the all new Yahoo! Security Centre. http://uk.security.yahoo.com

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


Re: [Haskell-cafe] Haskell versus Lisp

2005-09-16 Thread Harri Haataja
On Fri, Sep 16, 2005 at 12:34:57PM +0100, Mark Carter wrote:
 This is not a troll, honest, so please bear with me ...
 
 It struck me that Lisp was, perhaps, the Ultimate Programming
 Language, the One True Language to rule them all; except that I always
 kept  abandoning it for one reason or another (fiddly installation,
 lack of libraries, compatability problems,  cost, possible license
 issues, etc.). My current foray in Haskell seems encouraging.
 wxHaskell installed a breeze, and seems quite usable (even though I'm
 a raw n00b to the language, and admittedly haven't grokked the
 semantics, and all this  cid:part1.01000702.09000407@yahoo.co.uk IO
 a - IO () business). On the one hand, it  seems kinda academic, but
 on the other, it looks like it wants to be practical, too.

 Bearing this in mind, and hoping you can see where I'm coming from, I 
 think my question is: shouldn't you guys be using Lisp?

Given the words above, I wonder why the question is this way around :)

-- 
 Aqua Regis is HCl+H2SO4, and attacks gold.
While applying it to a luser, remember to sing
What a Friend We Have In Regis.
-- Patrick Wade
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Basic Haskell Types Question

2005-09-16 Thread Adam Wyner

Hi,

I have a basic question about how output types are reported.  I'm using 
Hugs.


Suppose I have the following, where the type String is predefined in
the Prelude as [Char].

type PropList = [String]

atomicProps1 :: PropList
atomicProps1 = [prop1]

And I have a function on expressions of type PropList which takes every 
string

from the input list and prefixes the string neg- to it.

negationAtomicProps :: PropList - PropList
negationAtomicProps inPropsList = [ neg- ++ inString | inString -
   inPropsList]

So, with the following, I get the right result:

 negationAtomicProps atomicProps1
[neg-prop1]

The types for the parts are right:

 :t negationAtomicProps
negationAtomicProps :: PropList - PropList

 :t atomicProps1
atomicProps1 :: PropList

But, what I don't understand or like is that the type of the whole
is given as [[Char]], not what I thought it would be, namely PropList.
Nor is it [String].

 :t negationAtomicProps atomicProps1
negationAtomicProps atomicProps1 :: [[Char]]

I really want to get the following sort of report for the type:

negationAtomicProps atomicProps1 :: PropList

The reason I want this is that in more complex cases, it will be easier
to see what is going wrong (as the functions are developed) if I can see
the types I want.

Am I supposed to be using newtype or data declarations here?  How would
I do this?  I looked around for information in the usual sources,
but haven't found an answer.

Thanks,
Adam Wyner

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


Re: [Haskell-cafe] Haskell versus Lisp

2005-09-16 Thread Malcolm Wallace
Mark Carter [EMAIL PROTECTED] writes:

 Bearing this in mind, and hoping you can see where I'm coming from, I 
 think my question is: shouldn't you guys be using Lisp?

One of the early implementations of Haskell (the Yale Haskell Compiler,
now defunct) was written in Common Lisp.

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


Re: [Haskell-cafe] Basic Haskell Types Question

2005-09-16 Thread Ketil Malde
Adam Wyner [EMAIL PROTECTED] writes:

 I really want to get the following sort of report for the type:
 negationAtomicProps atomicProps1 :: PropList

GHCi seems to get this right.  Is that an option for you?

-k
-- 
If I haven't seen further, it is by standing in the footprints of giants

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


Re: [Haskell-cafe] Haskell versus Lisp

2005-09-16 Thread David Roundy
On Fri, Sep 16, 2005 at 12:34:57PM +0100, Mark Carter wrote:
 Bearing this in mind, and hoping you can see where I'm coming from, I 
 think my question is: shouldn't you guys be using Lisp?

Lisp is impure, weakly typed and has way too many parentheses.  Why would
we use lisp? It seems to be lacking almost all the advantages of Haskell,
and have an ugly, inflexible syntax to boot.

Obviously I don't like lisp, and I also greatly dislike parentheses,
sometimes irrationally so... as is reflected by my excessive use of the $
operator.  And I abhor dynamcially typed languages... although perl isn't
too bad (it goes all the way, and even perl has some static typing--scalars
versus arrays versus hashes).  The more bugs the compiler is able to find
before you actually run your code, the better, in my opinion.
-- 
David Roundy
http://www.darcs.net
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Haskell versus Lisp

2005-09-16 Thread Mark Carter

Harri Haataja wrote:

On Fri, Sep 16, 2005 at 12:34:57PM +0100, Mark Carter wrote:

This is not a troll, honest, so please bear with me ...

It struck me that Lisp was, perhaps, the Ultimate Programming
Language, the One True Language to rule them all; except that I always
kept  abandoning it for one reason or another (fiddly installation,
lack of libraries, compatability problems,  cost, possible license
issues, etc.). My current foray in Haskell seems encouraging.
wxHaskell installed a breeze, and seems quite usable (even though I'm
a raw n00b to the language, and admittedly haven't grokked the
semantics, and all this  cid:part1.01000702.09000407@yahoo.co.uk IO
a - IO () business). On the one hand, it  seems kinda academic, but
on the other, it looks like it wants to be practical, too.


Bearing this in mind, and hoping you can see where I'm coming from, I
think my question is: shouldn't you guys be using Lisp?


Given the words above, I wonder why the question is this way around :)

The thing that struck me as being really cool about Lisp is the whole  
macro and the code is data idea. In the book Practical Common Lisp 
they show how data could be expressed as lists, which you could then 
easily serialise and deserialise to/from a file. How cool is that?! Plus 
you can use macros to extend the language.


Alas, pulling against this seems to be a number of minuses. The 
commercial Lisp implementations may be good, but what wannabe hacker is 
going to fork out the cash for those babies? The free ones that work on 
Windows are GPL, which means that although somebody might be tempted to 
use them for personal projects, he is not going to sell the idea to his 
boss that stuff should be developed in Lisp. Plus there are the 
fragmentation issues. I managed to get wxCL (wxWidgets for Common Lisp) 
to install and run on CLISP. I figured that ODBC connectivity should be 
next on the list, and found that I needed defsystem to make it run. So 
then I have to track down defsystem, get that installed, etc. etc.. It 
reminds me of one of those adventure games from my ZX81 days. In order 
to catch the bird you need the cage and the seed, but oh dear, you're 
carrying the rod which scares the bird, and so on. It's horribly 
complicated. Well, the following page goes into far greater detail than 
I ever could:

http://c2.com/cgi/wiki?WhyWeHateLisp
I daren't post this message on comp.lang.lisp you understand, as that 
would just be inviting Electric Death, as Douglas Adamas might say.




___ 
To help you stay safe and secure online, we've developed the all new Yahoo! Security Centre. http://uk.security.yahoo.com

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


Re: [Haskell-cafe] Haskell versus Lisp

2005-09-16 Thread Cale Gibbard
On 16/09/05, Mark Carter [EMAIL PROTECTED] wrote:
 This is not a troll, honest, so please bear with me ...
 
 I'm a C/C++/VBA programmer (although the former 2 are several years old
 for me), with a sprinkling of Python. Needless to say, I was looking to
 see if there were any better ways of doing things. I've given things
 like Ruby and Scheme a bit of peck, and failed to get particularly
 enthusiastic about them. Two very interesting choices, though, appear to
 be Lisp and Haskell. It struck me that Lisp was, perhaps, the Ultimate
 Programming Language, the One True Language to rule them all; except
 that I always kept  abandoning it for one reason or another (fiddly
 installation, lack of libraries, compatability problems,  cost, possible
 license issues, etc.). My current foray in Haskell seems encouraging.
 wxHaskell installed a breeze, and seems quite usable (even though I'm a
 raw n00b to the language, and admittedly haven't grokked the semantics,
 and all this  cid:part1.01000702.09000407@yahoo.co.uk IO a - IO ()
 business). On the one hand, it  seems kinda academic, but on the other,
 it looks like it wants to be practical, too.
 
 Bearing this in mind, and hoping you can see where I'm coming from, I
 think my question is: shouldn't you guys be using Lisp?
 
 

Well, there are a number of reasons which people might have for
choosing one over the other. I think you'll find that many Haskellites
are familiar with one or more variants of lisp and ML.

I'll try to provide some reasons that I find Haskell a fun and
pleasant programming language to write things in. (Actually, a fair
bit moreso than any other language that I've come across.)

One is that Haskell is lazily evaluated, and I really find that a lot
more natural than strict evaluation. It opens up a lot of ways of
writing code and thinking about code which would otherwise be
unavailable. In a strict language, you have to jump through some hoops
whenever infinite or very large amounts of data come along. You tend
to have to use different methods than you would for small data
structures in order to compute only small parts at any one time, and
throw away the parts that you're done with explicitly. In a lazy
language, a list is a list, and a tree is a tree, and the same
functions and techniques apply to them. Even if your data are
moderately sized, there are often times that the easiest algorithm to
write involves a large intermediate data structure, though you'll only
look at it one piece at a time, and maybe won't look at all of it.
With lazy evaluation, you're not penalized for doing things that way.

Of course, there are times when you really want strict evaluation, and
Haskell has ways to provide that. I find that they are relatively
rare.

Another reason is that it is statically type checked. The type system
in Haskell is quite expressive, and I find that it helps to catch bugs
to an incredible extent, and also to structure the way that you think
about code. With algebraic datatypes and the collection of standard
data structures in the libraries, you also don't lose very much
flexibility over dynamically typed structures.

The type system also helps you jump into unfamiliar code. People tend
to write Haskell code which uses types in order to distinguish and
catch those things which are obviously incorrect. When trying to sort
out how a piece of code works, or how to extend it, there is a
somewhat more restricted way that things could be fitting together at
any one point, so it's easier to figure out what's going on, and pin
down the places where you might want to extend things. You can often
go quite a long way in understanding code just by looking at the
types.

I also find that just through using Haskell, and being around the
Haskell community, I expose myself to a lot of exciting computer
science research. I'm still quite impressed that category theory has
found practical applications so quickly. :) Haskell people in general
seem to be experimenting with new kinds of abstractions and seeing how
far they can be taken in being put to practical use. Haskell itself
seems to be developing in directions which serve this experimentation,
and at the same time is becoming more and more practical.

Anyway, these are just some highlights of what I find fun about it,
and of course none of this is meant in any way to detract from all the
other great languages out there. Exploring different programming
languages is a lot of fun and can really expand the way that you think
about code. I encourage you to do so as much as possible.

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


Re: [Haskell-cafe] Haskell versus Lisp

2005-09-16 Thread Glynn Clements

David Roundy wrote:

  Bearing this in mind, and hoping you can see where I'm coming from, I 
  think my question is: shouldn't you guys be using Lisp?
 
 Lisp is impure, weakly typed and has way too many parentheses.  Why would
 we use lisp? It seems to be lacking almost all the advantages of Haskell,
 and have an ugly, inflexible syntax to boot.

The ability to dynamically generate, manipulate and analyse code in a
structured manner provides a flexibility which is unmatched by any
other language I know of.

A good example is Emacs; lisp is entirely the right language for that,
IMHO.

-- 
Glynn Clements [EMAIL PROTECTED]
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Haskell versus Lisp

2005-09-16 Thread Joel Reymont
I have faced these issues twice, always starting from Lisp and moving  
on somewhere else. There's more on my travails at http:// 
wagerlabs.com/tech and http://wagerlabs.com/uptick.


I implemented a poker engine in Lisp but it appeared that to deliver  
it on Windows, Linux and Mac OSX I would need to buy 3 commercial  
Lisp licenses. The total cost would have been about 4K euro +  
maintenance fees for LispWorks and about 18K USD + 25% maintenance  
fees for Allegro CL. Allegro also comes with royalties of less than  
10%. Windows Lisps are GPL so I could not use them.


What turned me off with poker was trying to write a Reliable UDP  
protocol handler and having a lot of trouble with threads and timers  
for some reasons. Fortunately, I discovered Erlang, quickly rewrote  
my poker backend and have been happy since. That is until I  
discovered Haskell :-). I'm now thinking of rewriting various chunks  
of the engine in Haskell (hand ranking for example) to see how it  
feels and what I gain. Concurrent Haskell coupled with transactional  
memory looks attractive as well.


I also started with Lisp for my trading systems project (Uptick) but  
was turned off even faster this time. I investigated what it would  
take to write code that overloaded +, *, etc. for arrays or lists and  
what it would take to optimize this code. It's possible but it's not  
elegant or pleasant.


I love a good challenge and the challenge of learning Haskell is like  
no other. It does require me to rewire my brain and to think  
different. There are a number of applications where Haskell fits  
nicely, google for papers on audio processing, robotics (Yampa), etc.  
I have yet to find an application where Lisp would shine over  
everything else.


Joel

On Sep 16, 2005, at 3:06 PM, Mark Carter wrote:

Alas, pulling against this seems to be a number of minuses. The  
commercial Lisp implementations may be good, but what wannabe  
hacker is going to fork out the cash for those babies? The free  
ones that work on Windows are GPL, which means that although  
somebody might be tempted to use them for personal projects, he is  
not going to sell the idea to his boss that stuff should be  
developed in Lisp.

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


Re: [Haskell-cafe] Haskell versus Lisp

2005-09-16 Thread Udo Stenzel
Mark Carter wrote:
 The free ones that work on 
 Windows are GPL, which means that although somebody might be tempted to 
 use them for personal projects, he is not going to sell the idea to his 
 boss that stuff should be developed in Lisp.

Nonsense.  The copyright notice for GNU CLisp specifically clarifies
that you are allowed to distribute your clisp programs, whether
interpreted or compiled, under any terms you like.  Just don't touch
clisp internals.  Accompany the program with the source for CLisp and
you are clear.

Anyway, I knew I didn't want to learn lisp when I heard that an
implementation is not required to optimize tail calls.  That means deep
recursions are unreliable.  A functional language in which you have
to iterate instead of recurse?  Impossible!


Udo.
-- 
Did you know that if you took all the economists in the world and lined
them up end to end, they'd still point in the wrong direction?


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


[Haskell-cafe] And another basic typing question -- empty list

2005-09-16 Thread Adam Wyner

Hi,

I have some questions about using the empty list in Hugs.  In June 2001, 
this
was raised as a bug in hugs (see Hugs-Bugs Archives).  References 
therein to
a bug list on S. Thompson's pages come up a dead end.  I haven't found 
any follow
up or solution to this discussed.  I would particularly like to use an 
empty list

in the Trex module of Hugs.

Suppose I have two expressions:

emptyListA = null

emptyListB = []

emptyListA is apparently a function from empty lists to Bool.
I would have thought that emptyListB would just be the empty
list and output it as such.

 :t emptyListA

emptyListA :: [a] - Bool

 emptyListA []
True

The problem is that there is no show function for
emptyListB, which is just []

 emptyListB
ERROR - Cannot find show function for:
*** Expression : emptyListB
*** Of type: [a]

What I would like, simply is:

emptyListB
[]

More to my purpose, I would like to use the empty list as a value
of a record in Trex.  For instance, while the first example below
gives a good result, the second example has no show function.
Looking at the Trex module, it would seem that there is a show
function for the empty list (?? but frankly, I have never touched
this area of haskell, so I haven't given it much thought).

Sample command line I/O.

 (a = 'a', b = [2])
(a = 'a', b = [2])

 (a = 'a', b = [])
ERROR - Cannot find show function for:
*** Expression : (a = 'a', b = [])
*** Of type: Rec (a :: Char, b :: [a])

Clearly, the problem is the empty list labelled b.

What I want is the following sort of result:

 (a = 'a', b = [])
(a = 'a', b = [])

Further along, what I want is to have values for the field labelled b
to be lists which contain something.  So, in one case, the value is
[], while in another it is [2], say.  Moreover, I want to define
a type which has a label with values of type lists.  That is, I want to 
have

a record something like Rec (a :: Char, b :: List).
However, List is not a basic data type.  And in any case, the values of 
labels
cannot show empty lists.  I'm unsure whether Trex or any record type can 
handle this.


Here are some examples.
The following is OK.

type TestList01 = Rec (a :: Char, b :: [Char])

testList01 :: TestList01
testList01 = (a = 'a', b = b)

Input and output are:
 testList01
(a = 'a', b = b)

ComplexActions01 :t (a = 'a', b = b)
(a = 'a', b = b) :: Rec (a :: Char, b :: [Char])

But the following type is uninterpretable:

type TestList02 = Rec (a :: Char, b :: [])

ERROR ComplexActions01.lhs:196 - Illegal type [] in constructor
application.

Suggestions about how to treat empty lists?

Thanks,
Adam Wyner

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


Re: [Haskell-cafe] Haskell versus Lisp

2005-09-16 Thread Wolfgang Jeltsch
Am Freitag, 16. September 2005 15:06 schrieb Mark Carter:
 Plus you can use macros to extend the language.

I don't know really about LISP macros but aren't they a bit like Template 
Haskell?

Since Haskell (even without Template Haskell) is a small but flexible language 
you can construct domain-specific langauges just by writing a library and 
using Haskell with this library as your domain-specific language.  I don't 
know LISP very much but I suppose that there are many things you can do in 
LISP which you can also do in Haskell.

Two big advantages of Haskell over LISP are lazy evaluation and its strong, 
flexible type system. Lazy evaluation makes the code a lot easier, cleaner, 
more functional.  Strong typing may be too restricting if the type system is 
not powerful enough.  But since Haskell's type system is very powerful, I 
practically never miss dynamic typing.

 [...]

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


Re: [Haskell-cafe] Haskell versus Lisp

2005-09-16 Thread Wolfgang Jeltsch
Am Freitag, 16. September 2005 15:29 schrieb Glynn Clements:
 David Roundy wrote:
   Bearing this in mind, and hoping you can see where I'm coming from, I
   think my question is: shouldn't you guys be using Lisp?
 
  Lisp is impure, weakly typed and has way too many parentheses.  Why would
  we use lisp? It seems to be lacking almost all the advantages of Haskell,
  and have an ugly, inflexible syntax to boot.

 The ability to dynamically generate, manipulate and analyse code in a
 structured manner provides a flexibility which is unmatched by any
 other language I know of.

 A good example is Emacs; lisp is entirely the right language for that,
 IMHO.

Could you explain this a bit more, please?  To the moment, I cannot imagine 
cases where you need LISP's way of code analysis and manipulation because 
Haskell's capabilities are not sufficient.

In Haskell, code is data too because code in the sense of imperative actions 
is described by IO values.  You cannot analyse them.  But you can use your do 
expressions etc. to construct action descriptions with a more general type 
like MonadIO m = m a.  Then you can instantiate m with a monad whose values 
store part of the action's structure so that this information can be used 
later.  Or you use a monad which doesn't keep structural information to use 
it for later processing but which does the processing upon construction.

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


Re: [Haskell-cafe] And another basic typing question -- empty list

2005-09-16 Thread Wolfgang Jeltsch
Am Freitag, 16. September 2005 16:02 schrieb Adam Wyner:
 [...]

 Suppose I have two expressions:

 emptyListA = null

 emptyListB = []

 emptyListA is apparently a function from empty lists to Bool.

emptyListA is a function from *arbitrary* lists to Bool.

 [...]

 The problem is that there is no show function for
 emptyListB, which is just []

   emptyListB

 ERROR - Cannot find show function for:
 *** Expression : emptyListB
 *** Of type: [a]

The type [a] means forall a. [a], i.e., you can replace the a in [a] with an 
arbitrary type t and the expression in question has type [t].  This is only 
true for the empty list.  [] has type [Integer], [String] etc.

A show function which only accepted empty lists would have type
(forall a. [a]) - String.  This is not possible in Haskell 98.  You would 
need explicit universal quantification.

What is possible in Haskell is to give show the type [a] - String.  This 
means forall a. ([a] - String), i.e., show has every type [t] - String 
where t is an arbitrary type.  This would allow show to be applied to 
non-empty lists whose elements itself cannot be shown via the show functions.  
This has, of course, to be disallowed.  The type [a] - String is too 
general.

The actual type of show in Haskell 98 is Show a = [a] - String.  The element 
type has to be an instance of Show which means that its values can be shown 
via the show function.

 What I would like, simply is:
  emptyListB

 []

You can specialize the type of emptyListB:

input: emptyListB :: [Int]
output: []

 [...]

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


Re: [Haskell-cafe] wxHaskell: getting a checkbox state

2005-09-16 Thread Remi Turk
On Fri, Sep 16, 2005 at 12:12:50AM +0200, Sebastian Sylvan wrote:
 On 9/14/05, Mark Carter [EMAIL PROTECTED] wrote:
  The problem I was having before was that I was trying to create a
  separate function onCbEdit, thus:
 cbEdit - checkBox p1 [text := Edit Mode, on command :=  onCbEdit
  textlog   ]
  This had the problem that onCbEdit basically needed to have its control
  passed in (i.e. cbEdit) as a parameter in order to inspect its state. So
  I wanted to do something like:
 cbEdit - checkBox p1 [text := Edit Mode, on command :=  onCbEdit
  textlog   cbEdit ]
  Except you can't do that, because  cbEdit isn't yet defined. But your
  suggestion gets 'round that. In the main loop, I now do:
cbEdit - checkBox p1 [text := Edit Mode ]
set cbEdit [ on command :=  onCbEdit textlog  cbEdit ]
 
 Some extension (I think) to GHC allows mdo-notation (recursive do). So
 you can do this:
 mdo -- yadayada
cbEdit - checBox p1 [text := Edit Mode, on comand :=
 onCbEdit textlog cbEdit]
-- yadayada...

No extensions are needed, actually:

  cbEdit - checBox p1 [text := Edit Mode, on comand ::= onCbEdit textlog]
   ^^^
   Note the double colon.

Prelude Graphics.UI.WX :t (:=)
(:=) :: Attr w a - a - Prop w

Prelude Graphics.UI.WX :t (::=)
(::=) :: Attr w a - (w - a) - Prop w

Prelude Graphics.UI.WX :t (:~)
(:~) :: Attr w a - (a - a) - Prop w

Prelude Graphics.UI.WX :t (::~)
(::~) :: Attr w a - (w - a - a) - Prop w

Happy hacking,
Remi

-- 
Nobody can be exactly like me. Even I have trouble doing it.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Haskell versus Lisp

2005-09-16 Thread Creighton Hogg
On Fri, 16 Sep 2005, Mark Carter wrote:

 This is not a troll, honest, so please bear with me ...
 
 I'm a C/C++/VBA programmer (although the former 2 are several years old 
 for me), with a sprinkling of Python. Needless to say, I was looking to 
 see if there were any better ways of doing things. I've given things 
 like Ruby and Scheme a bit of peck, and failed to get particularly 
 enthusiastic about them. Two very interesting choices, though, appear to 
 be Lisp and Haskell. It struck me that Lisp was, perhaps, the Ultimate 
 Programming Language, the One True Language to rule them all; except 
 that I always kept  abandoning it for one reason or another (fiddly 
 installation, lack of libraries, compatability problems,  cost, possible 
 license issues, etc.). My current foray in Haskell seems encouraging. 
 wxHaskell installed a breeze, and seems quite usable (even though I'm a 
 raw n00b to the language, and admittedly haven't grokked the semantics, 
 and all this  cid:part1.01000702.09000407@yahoo.co.uk IO a - IO () 
 business). On the one hand, it  seems kinda academic, but on the other, 
 it looks like it wants to be practical, too.
 
 Bearing this in mind, and hoping you can see where I'm coming from, I 
 think my question is: shouldn't you guys be using Lisp?


As someone else that has been learning both Haskell and 
Lisp, I think you should really look at Haskell as a 
wonderful experiment.  Essentially, while Lisp can do pretty 
much anything, it isn't perfect and shouldn't be the last 
word., I don't think we should be satisfied with a language just 
the way it is.  Haskell is very, very different than most languages.  
It's *purely* functional and lazy evaluating.  The latter is 
most interesting to me from the compiler writing aspect.  
When I have a little more free time and a little more 
experience I'd love to have a deeper look at ghc and 
understand how it works.
In essence though, I think that Haskell is worth learning 
simply because it tries something different.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] wxHaskell: getting a checkbox state

2005-09-16 Thread Mark Carter

Remi Turk wrote:


No extensions are needed, actually:

 cbEdit - checBox p1 [text := Edit Mode, on comand ::= onCbEdit textlog]
  ^^^
   Note the double colon.

Happy hacking,
Remi
 


Many thanks.

As it happens, I decided that ODBC connectivity might be a nice thing to 
have. HToolkit seemed the one to go for, so I downloaded it for a quick 
spin. After an initial minor bit of configuration hoopla (don't get me 
started with the Lisp equivalent; plain-odbc needs defsystem, which runs 
insides CLOCC, plus uffi, plus other stuff that I've lost track of; it's 
like peeling back the layers of an onion, only to find more layers. 
Also, like onions, they are capable of making a grown man cry). I 
created an MS Access database, a DSN, and fired up one of the examples. 
And it worked!


Haskell's stock is definitely going up, as far as I'm concerned.




___ 
Yahoo! Messenger - NEW crystal clear PC to PC calling worldwide with voicemail http://uk.messenger.yahoo.com

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


Re: [Haskell-cafe] Haskell versus Lisp

2005-09-16 Thread Mark Carter

Wolfgang Jeltsch wrote:


Am Freitag, 16. September 2005 15:06 schrieb Mark Carter:
 


Plus you can use macros to extend the language.
   



I don't know really about LISP macros but aren't they a bit like Template 
 

I wrote a Lisp macro once, and realised that it had a power that I 
hadn't seen before (the actual problem I was trying to solve that I 
wanted a logger that, given a variable, printed its name and value). 
That represented my one dip into Lisp macros, so it's fair to say that 
I'm not qualified to talk on either of Lisp or Haskells metaprogramming 
facilities. All I know is, if Haskell Templates provide no greater power 
than those of C++, be prepared for the Lispers to be, shall we say,  
somewhat condescending about them. ;)




___ 
To help you stay safe and secure online, we've developed the all new Yahoo! Security Centre. http://uk.security.yahoo.com

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


Re: [Haskell-cafe] Haskell versus Lisp

2005-09-16 Thread David Roundy
On Fri, Sep 16, 2005 at 02:29:33PM +0100, Glynn Clements wrote:
 David Roundy wrote:
   Bearing this in mind, and hoping you can see where I'm coming from, I
   think my question is: shouldn't you guys be using Lisp?
  
  Lisp is impure, weakly typed and has way too many parentheses.  Why
  would we use lisp? It seems to be lacking almost all the advantages of
  Haskell, and have an ugly, inflexible syntax to boot.
 
 The ability to dynamically generate, manipulate and analyse code in a
 structured manner provides a flexibility which is unmatched by any
 other language I know of.

True, if you want to write code to modify code, lisp would be nice
(everything is a list)... but that's related to my problem with its syntax.
Lisp seems to be designed for machines to parse easily without regard to
ease of human parsing.  That seems backwards to me.  On one level, an
objection to syntax is pretty lame, but on the other hand,

CAVEAT: I know nothing about lisp macros... my lisp knowledge is basically
from one course over ten years ago, plus some experience with configuring
emacs and with a photonics code (mpb) that used guile for its input files.
-- 
David Roundy
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Haskell versus Lisp

2005-09-16 Thread Jacques Carette

Glynn Clements wrote:


Every other language (including Haskell) tends to have the problem
that eventually you will encounter a situation where the language's
own worldview gets in the way.

Or, to put it another way: if Haskell is so flexible, why do we need
Template Haskell? I can't imagine a Template Lisp; it would just be
Lisp.
 

I was just about to say something very similar.  So to add a new point:  
Why is there a partial evaluator for full Scheme 
(http://www.informatik.uni-freiburg.de/proglang/software/pgg/) but none 
for full Haskell (or full ML for that matter)?  The problem is 
considerably harder - see the papers listed at 
http://partial-eval.org/scheme_pe.html.


The issue there is definitely one of worldview.  The Haskell type system 
(and the ML type system as well) have a wordview that is incompatible 
with very powerful code manipulations.  That is why Template Haskell is 
*untyped*, and why MetaOCaml (www.metaocaml.org) puts serious 
restrictions on what can be done with code so as to prevent unsoundness.


However, Gilmore's work on Intensional Type Theory 
(http://www.cs.ubc.ca/spider/gilmore/) looks very promising to me as a 
method to attack this worldview problem.  Others have tried to use modal 
logic (mostly S4), but I personally don't believe that is the right way 
to go.


Jacques

PS: yes, I know about 
http://www.cs.chalmers.se/~rjmh/PECourse/Exercises/PE.html and 
http://www.informatik.uni-freiburg.de/proglang/research/software/mlope/.

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


[Haskell-cafe] wxHaskell: convenience functions

2005-09-16 Thread Mark Carter



I'm experimenting with wxHaskell, and I've got something like:

main = run mainFrame

mainFrame = do -- main application frame
   ...
   cbEdit - checkBox p1 [text := Edit Mode,  on command ::=  
onCbEdit textlog]

   ...
 where
   ...

It would be useful to have some convenience function, let's say, 
isEditing, which works out whether cbEdit is checked, or not. That way, 
one could just pass this in as a parameter without requiring any extra 
code. The problem is, I can't see how it can be done. I've tried various 
things in the main section, and nothing worked. I tried putting the 
following defintion into the where clause:


   isEditing = do
   checkedp - get cbEdit checked
   return checkedp

but the compiler complained that cbEdit is not in scope. I /could/ pass 
in cbEdit as a parameter to isEditing, but I'd rather not.




___ 
To help you stay safe and secure online, we've developed the all new Yahoo! Security Centre. http://uk.security.yahoo.com

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


Re: [Haskell-cafe] wxHaskell: convenience functions

2005-09-16 Thread Mark Carter
Actually, I can see how my requirement of not wanting to pass in cbEdit 
might not be so good. From an FP point of view, that's just asking for 
trouble. A better solution would appear to be to put the cbEdit in as a 
parameter, and just face the fact that all callers will be required to 
pass an extra parameter.


Mark Carter wrote:




I'm experimenting with wxHaskell, and I've got something like:

main = run mainFrame

mainFrame = do -- main application frame
   ...
   cbEdit - checkBox p1 [text := Edit Mode,  on command ::=  
onCbEdit textlog]

   ...
 where
   ...

It would be useful to have some convenience function, let's say, 
isEditing, which works out whether cbEdit is checked, or not. That 
way, one could just pass this in as a parameter without requiring any 
extra code. The problem is, I can't see how it can be done. I've tried 
various things in the main section, and nothing worked. I tried 
putting the following defintion into the where clause:


   isEditing = do
   checkedp - get cbEdit checked
   return checkedp

but the compiler complained that cbEdit is not in scope. I /could/ 
pass in cbEdit as a parameter to isEditing, but I'd rather not.



   
___ To help 
you stay safe and secure online, we've developed the all new Yahoo! 
Security Centre. http://uk.security.yahoo.com

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





___ 
To help you stay safe and secure online, we've developed the all new Yahoo! Security Centre. http://uk.security.yahoo.com

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


Re: [Haskell-cafe] wxHaskell: convenience functions

2005-09-16 Thread Mark Carter

Re: [Haskell-cafe] wxHaskell: convenience functions

Actually, I can see how my requirement of not wanting to pass in cbEdit 
might not be so good. From an FP point of view, that's just asking for 
trouble. A better solution would appear to be to put the cbEdit in as a 
parameter, and just face the fact that all callers will be required to 
pass an extra parameter.


Mark Carter wrote:



 I'm experimenting with wxHaskell, and I've got something like:

 main = run mainFrame

 mainFrame = do -- main application frame
...
cbEdit - checkBox p1 [text := Edit Mode,  on command ::=  
onCbEdit textlog]

...
  where
...

 It would be useful to have some convenience function, let's say, 
isEditing, which works out whether cbEdit is checked, or not. That way, 
one could just pass this in as a parameter without requiring any extra 
code. The problem is, I can't see how it can be done. I've tried various 
things in the main section, and nothing worked. I tried putting the 
following defintion into the where clause:


isEditing = do
checkedp - get cbEdit checked
return checkedp

 but the compiler complained that cbEdit is not in scope. I /could/ 
pass in cbEdit as a parameter to isEditing, but I'd rather not.



   
 ___ To help 
you stay safe and secure online, we've developed the all new Yahoo! 
Security Centre. http://uk.security.yahoo.com

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







___ 
Yahoo! Messenger - NEW crystal clear PC to PC calling worldwide with voicemail http://uk.messenger.yahoo.com

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


Re: [Haskell-cafe] wxHaskell: convenience functions

2005-09-16 Thread David Roundy
On Fri, Sep 16, 2005 at 06:30:54PM +0100, Mark Carter wrote:
 Actually, I can see how my requirement of not wanting to pass in cbEdit 
 might not be so good. From an FP point of view, that's just asking for 
 trouble. A better solution would appear to be to put the cbEdit in as a 
 parameter, and just face the fact that all callers will be required to 
 pass an extra parameter.

It depends on where you want this convenience function to be visible.  You
could define

mainFrame = do
  ...
  cbEdit - checkBox p1 [text := Ed...
  let isEditing = get cbEdit checked
  ...

and you're perfectly fine.  The catch is that isEditing is now only visible
in this scope.  You could pass isEditing to another function without
causing any trouble.  It might be cleaner than passing cbEdit around (for
example, if the mechanism by which the isEditing state is stored ever
changes).
-- 
David Roundy
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re[2]: [Haskell-cafe] Haskell versus Lisp

2005-09-16 Thread Bulat Ziganshin
Hello Wolfgang,

Friday, September 16, 2005, 6:30:45 PM, you wrote:

WJ more functional.  Strong typing may be too restricting if the type system is
WJ not powerful enough.  But since Haskell's type system is very powerful, I 
WJ practically never miss dynamic typing.

really, we have dunamic typing in current GHC:

1) rank-2 types
2) Data.Dynamic



-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]



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


Re[2]: [Haskell-cafe] Haskell versus Lisp

2005-09-16 Thread Bulat Ziganshin
Hello Mark,

Friday, September 16, 2005, 7:42:46 PM, you wrote:
MC facilities. All I know is, if Haskell Templates provide no greater power
MC than those of C++, be prepared for the Lispers to be, shall we say,  
MC somewhat condescending about them. ;)

Template Haskell has nothing common with C templates, it's îíûå a
typeful UNIVERSAL preprocessor. C templates equivalent to Haskell
polymorhic procedures/types, which exist from the language start



-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]



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


[Haskell-cafe] Newbie syntax question

2005-09-16 Thread André Vargas Abs da Cruz

Hi,

   I have been using Haskell for a few weeks now and I can say that I 
am totally impressed by how easy it is to program with it. I am now 
doing some small exercises to get used to the language syntax and I have 
a little (newbie) question:


   Suppose I declare a function foo like:

   foo :: [Double] - Int - Int
   foo a b

   Suppose now that I want to apply this function to a list that 
contains lists of doubles (something like [[Double]]) using map, but I 
want to keep the 'b' parameter fixed (with a value of 5 for instance). 
Is it possible to use map passing the function foo with the 2nd argument 
only ? In other words, if I wrote this function like:


   foo :: Int - [Double] - Int

   I could clearly call it with:

   map (foo 5) my_list_of_lists_of_doubles

   But how to do that (if possible) when I invert the parameters list ?!

   Thanks in advance,
   Andre Abs da Cruz
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Newbie syntax question

2005-09-16 Thread André Vargas Abs da Cruz

That's exactly what i was looking for. Thank you very much !!!

Cheers,
André

ChrisK wrote:


There is the flip function which changes the order of the first 2
parameters

Prelude :t flip
flip :: forall c a b. (a - b - c) - b - a - c

So I think
map ( (flip foo) 5 ) my_list_of_lists_of_doubles
will work, as will using a lambda expression
map (\x - foo x 5) may_list_of_lists_of_doubles


André Vargas Abs da Cruz wrote:
 


Hi,

  I have been using Haskell for a few weeks now and I can say that I am
totally impressed by how easy it is to program with it. I am now doing
some small exercises to get used to the language syntax and I have a
little (newbie) question:

  Suppose I declare a function foo like:

  foo :: [Double] - Int - Int
  foo a b

  Suppose now that I want to apply this function to a list that
contains lists of doubles (something like [[Double]]) using map, but I
want to keep the 'b' parameter fixed (with a value of 5 for instance).
Is it possible to use map passing the function foo with the 2nd argument
only ? In other words, if I wrote this function like:

  foo :: Int - [Double] - Int

  I could clearly call it with:

  map (foo 5) my_list_of_lists_of_doubles

  But how to do that (if possible) when I invert the parameters list ?!

  Thanks in advance,
  Andre Abs da Cruz
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
   




 



--
---
André Vargas Abs da Cruz

Laboratório de Inteligência Computacional Aplicada
Departamento de Engenharia Elétrica
Pontifícia Universidade Católica - Rio de Janeiro

http://www.ica.ele.puc-rio.br/

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


[Haskell-cafe] a new Monad

2005-09-16 Thread Malcolm Wallace
Microsoft has announced the following:

Developers can also expect a new scripting language for management
applications, called Monad.  Monad is an object-oriented language
based on .NET, and provides command-line based management while
enabling management services to be passed between different
commands.

http://www.theregister.co.uk/2005/09/16/microsoft_longhorn_server/

What a strange choice of name for a language...!  :-)

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


[Haskell-cafe] killing a running thread interactively

2005-09-16 Thread S. Alexander Jacobson


If I am running a server interactively. (using ghci).
Is there any way to kill its running threads without terminating the 
interpreter?


-Alex-

__
S. Alexander Jacobson tel:917-770-6565 http://alexjacobson.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Newbie syntax question

2005-09-16 Thread Neil Mitchell
 So I think
 map ( (flip foo) 5 ) my_list_of_lists_of_doubles
 will work, as will using a lambda expression
 map (\x - foo x 5) may_list_of_lists_of_doubles

I really like the `foo`  syntax.

map (`foo` 5) my_list

also works, without an auxiliary function and without a lambda. In
reality this gets de-sugared to a flip, but i prefer this syntax.
`foo` uses foo as an infix operator.

Thanks

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


Re: [Haskell] Re: [Haskell-cafe] Haskell versus Lisp

2005-09-16 Thread David F. Place


On Sep 16, 2005, at 6:26 PM, Glynn Clements wrote:


Haskell's safety and
consistency can get in the way, while Lisp's freedom can be quite
unsafe and inconsistent.


I have many years of experience designing and implementing commercial  
software in lisp and I strongly agree with the second part of this  
sentence.   However, my more recent experience with Haskell makes me  
doubt very much the first part.  Haskell's powerful type system  
hasn't in the least cramped my style and lazy evaluation eliminates  
99% of the need for macros in lisp.   (The other 1% is syntactic  
sugar of doubtful utility.) Since Haskell supports recursive  
polymorphic types it can easily handle all of the metaprogramming  
problems where lisp first made its mark.


I don't see any reason to continue to use lisp.

ps. This thread was on Haskell-cafe which seems more appropriate, so  
I'm bringing it back.



David F. Place
mailto:[EMAIL PROTECTED]

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


[Haskell-cafe] Use Haskell to extract GXL file (GXL representation)

2005-09-16 Thread Sara Kenedy
Dear you all,


Currently, I am working with GXL file (Graph eXchange Language). GXL 
is  a sublanguage of XML and  its syntax is based XML DTD.

In my work, I use GXL representation to represent a quantification:

 forall(x:Z|x = 3 and x^2 - 3x + 2 =0)

My objective is to write a Haskell module to extract the content of
the GXL file such that a computer algebra system (e.g, Matlab) or a
prover theorem (e.g, ICS) can read the content of GXL file.

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


[Haskell-cafe] Use Haskell to extract GXL representation

2005-09-16 Thread Sara Kenedy
Dear you all,


Currently, I am working with Haskell and GXL file (Graph eXchange Language). GXL
is  a sublanguage of XML and  its syntax is based on XML DTD.

1) In my work, I use GXL representation to represent a quantification
(e.g. forall(x:Z|x = 3 and x^2 - 3x + 2 =0))

2) My objective is to write a Haskell module to extract the content of
the GXL file such that a prover theorem (e.g, ICS) and a computer
algebra system (e.g, Matlab) can read the content of GXL file.

If any of you have experiences or any ideas about the problem, please
share with me.

I really appreciate for that.Thanks a lot.

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


[Haskell-cafe] Dread __DISCARD__

2005-09-16 Thread Steven Elkins
Hello everyone,

I'm a Haskell newbie trying out various programs from the web.  I'm
trying to compile one called bjpop-ray (from Bernie Pope, I think) and
I hit this at link-time:

ghc --make -O0 -package wx Main.hs -o bjpop-ray
Chasing modules from: Main.hs
Skipping  Data ( ./Data.hs, ./Data.o )
Skipping  Sphere   ( ./Sphere.hs, ./Sphere.o )
Skipping  Parser   ( ./Parser.hs, ./Parser.o )
Skipping  Vector   ( ./Vector.hs, ./Vector.o )
Skipping  Polygon  ( ./Polygon.hs, ./Polygon.o )
Skipping  RayTrace ( ./RayTrace.hs, ./RayTrace.o )
Skipping  Main ( Main.hs, Main.o )
Linking ...
/usr/bin/ld: Undefined symbols:
___DISCARD__
collect2: ld returned 1 exit status

I'm on Mac OS 10.4.2, using ghc 6.4 (from the haskell.org .dmg) and
gcc 4.0.0.  Other wxHaskell programs (the samples and my own
experiments) compile without tripping over this.

Googling __DISCARD__ led me to ...the binary on the ghc web site has
the evil __DISCARD__ mangler problem... on the darwinports bug
mailing list, so I guess I'm not the first person to see this.

Is there a workaround?  Does the Darwin port have the same problem? 
Should I just work on the many other things I've yet to grasp? 
Usually ghc works fine.

Thanks,
Steve


-- 
How wonderful it is that nobody need wait a single moment
before starting to improve the world.   -- Anne Frank
Paradise is exactly where you are
right now...only much, much better.-- Laurie Anderson
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Eq Type Class: Overloading (==)

2005-09-16 Thread Tom Hawkins

Hello,

Is it possible to overload (==) to a type other than a - a - Bool?

I have an abstract datatype that somewhat behaves like a C integer: a 
comparison returns a boolean represented as the same datatype:


(==) :: my_type - my_type - my_type

Thanks for any help!

-Tom

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


Re: [Haskell-cafe] Eq Type Class: Overloading (==)

2005-09-16 Thread ChrisK
You would have to preempt the Standard Prelude. For ghc there is a
command line switch I have neer used: -fno-implicit-prelude

See section 7.3.5 in the GHC user's guide for more.

There are some internal caveats:

However, the standard Prelude Eq class is still used for the equality
test necessary for literal patterns.



Tom Hawkins wrote:
 Hello,
 
 Is it possible to overload (==) to a type other than a - a - Bool?
 
 I have an abstract datatype that somewhat behaves like a C integer: a
 comparison returns a boolean represented as the same datatype:
 
 (==) :: my_type - my_type - my_type
 
 Thanks for any help!
 
 -Tom
 
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Eq Type Class: Overloading (==)

2005-09-16 Thread Cale Gibbard
On 16/09/05, Tom Hawkins [EMAIL PROTECTED] wrote:
 Hello,
 
 Is it possible to overload (==) to a type other than a - a - Bool?
 
 I have an abstract datatype that somewhat behaves like a C integer: a
 comparison returns a boolean represented as the same datatype:
 
 (==) :: my_type - my_type - my_type
 
 Thanks for any help!
 
 -Tom

You largely wouldn't want to -- the thing that makes the usual type
for (==) useful is that lots of functions make use of the Bool result
with if/then/else. If you change the Eq typeclass, then a large chunk
of the standard library is going to break, and it won't be all that
easy to correct, because if-then-else-expressions all expect a Bool.
You'd want to add a typeclass for boolean-interpretable values, and
fix up ghc to use it with if-expressions.

Haskell doesn't use ad-hoc polymorphism, so you're out of luck if you
want to keep the usual equality test around and have it overlap with
your function of another type. Further, there wouldn't be much point
to that kind of polymorphism, since functions requiring (==) to give a
Boolean result would simply break, and that would be nearly all of
them.

You can of course give the new kind of comparison another name though.
(===) isn't taken, for instance. You can even develop a similar
typeclass around it if you like. (Look how Eq is written in the
prelude.)

It may also be useful to have a function around which projects one of
your values down to a Bool. If you want to do that generically, you
may also want a class method which does that.

Here's an example of the sort of class you might want.

class Equative t where
   (===) :: t - t - t
   isTrue :: t - Bool
   isFalse :: t - Bool
   -- Minimal complete definition: (===) and one of isTrue or isFalse.
   isFalse = not . isTrue
   isTrue = not . isFalse

hope this helps,
 - Cale
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe