Re: silly question on \n

2000-04-28 Thread Michael Hudson
Sitzman <[EMAIL PROTECTED]> writes: > Hey all.. Gosh, this feels embarrassing to ask.. but how do I get a string > to print out with a carriage return in it? (like using \n in c++)... > > I want > > listBooks :: [Book] -> [String] > > listBooks [] = [] > > listBooks (Book lang year last first t

RE: Changing <- to :=

2000-04-28 Thread Mike Jones
Tim, I am aware that it is not an assignment, but rather a binding to a value. However, my intent is to model a system that has both declarative and imperative constructs, then build it in another language. If I can use :=, I can make it look more like the final system, which is good for demonstr

silly question on \n

2000-04-28 Thread Sitzman
Hey all.. Gosh, this feels embarrassing to ask.. but how do I get a string to print out with a carriage return in it? (like using \n in c++)... I want > listBooks :: [Book] -> [String] > listBooks [] = [] > listBooks (Book lang year last first title:bs) > = (lang++","++year++","++last++","++fi

Re: Changing <- to :=

2000-04-28 Thread Thimble Smith
On Fri, Apr 28, 2000 at 07:08:22PM -0700, Mike Jones wrote: > Is there a way to define (:=) to be (<-) in the context of a do? > The goal is to make the language look Pascal like for those who will use it. I'd say that goal is ill-concieved. If you are trying to help people learn functional pro

Changing <- to :=

2000-04-28 Thread Mike Jones
All, Is there a way to define (:=) to be (<-) in the context of a do? This would then allow: result = do initialize vi1 := Vi.create Vi.setValue vi1 5.5 Vi.enable vi1 vi2 := Vi.create Vi.setValue vi2 6.0 cond1 (isnt (Vi.enabled vi2)) (Vi.se

Re: When is it safe to cheat?

2000-04-28 Thread Jan Skibinski
On Sat, 29 Apr 2000, Fergus Henderson wrote: > On 28-Apr-2000, Jan Skibinski <[EMAIL PROTECTED]> wrote: > > > > When can I safely cheat haskell compiler/interpreter > > by pretending that I perform pure computations, > > when in fact they are not? > > That depends on what degree o

Re: When is it safe to cheat?

2000-04-28 Thread Fergus Henderson
On 28-Apr-2000, Erik Meijer <[EMAIL PROTECTED]> wrote: > Hi Jan, > > > When can I safely cheat haskell compiler/interpreter > > by pretending that I perform pure computations, > > when in fact they are not? > > If the computation is not pure, you cannot pretend it is. Indeed. And i

Re: When is it safe to cheat?

2000-04-28 Thread Fergus Henderson
On 28-Apr-2000, Frank Atanassow <[EMAIL PROTECTED]> wrote: > Jan Skibinski writes: > >When can I safely cheat haskell compiler/interpreter > >by pretending that I perform pure computations, > >when in fact they are not? Here is a real example, > >from my Md5Digest module which

Re: When is it safe to cheat?

2000-04-28 Thread Fergus Henderson
On 28-Apr-2000, Jan Skibinski <[EMAIL PROTECTED]> wrote: > > When can I safely cheat haskell compiler/interpreter > by pretending that I perform pure computations, > when in fact they are not? That depends on what degree of safety and portability you want. If you want the great

Re: When is it safe to cheat?

2000-04-28 Thread Lennart Augustsson
Jan Skibinski wrote: > digest :: String -> String > digest string > = unsafePerformIO ( > marshall_string_ string >>= \x1 -> > prim_Md5Digest_digest x1 >>= \x2 -> > unmarshall_string_ x2 >>= \x3 -> >

When is it safe to cheat?

2000-04-28 Thread Frank Atanassow
Jan Skibinski writes: > When can I safely cheat haskell compiler/interpreter > by pretending that I perform pure computations, > when in fact they are not? Here is a real example, > from my Md5Digest module which works fine in Hugs: I don't understand what is impure about

RE: When is it safe to cheat?

2000-04-28 Thread Erik Meijer
Hi Jan, > When can I safely cheat haskell compiler/interpreter > by pretending that I perform pure computations, > when in fact they are not? If the computation is not pure, you cannot pretend it is. > Here is a real example, > from my Md5Digest module which works fi

Call for 10 minute slots: Workshop on Generic Programming 2000

2000-04-28 Thread Johan Jeuring
Workshop on Generic Programming http://www.cs.uu.nl/~johanj/wgp2000/wgp2000cfp.html 6th July 2000 Ponte de Lima , Portugal Call for proposals for 10 minutes slots The one day Workshop on Generic Programming (see the

When is it safe to cheat?

2000-04-28 Thread Jan Skibinski
Facing a risk of being stomped all over again without reason, I nevertheless post this question to get to the bottom of things: When can I safely cheat haskell compiler/interpreter by pretending that I perform pure computations, when in fact they

Re: doubly linked lists

2000-04-28 Thread Chris Okasaki
The implementation that uses laziness to get true backpointers seems to have caught everybody's imagination. Several people have hinted at the big weakness of this implementation, but lest any beginners reading this thread be misled, let me just state that weakness explicitly -- it takes O(n) t

ANN: C->Haskell by anonymous CVS

2000-04-28 Thread Manuel M. T. Chakravarty
For those who prefer the thrill of the latest features over the safety of a tested release: C->Haskell is now available via anonymous CVS. Details at http://www.cse.unsw.edu.au/~chak/haskell/c2hs/#cvs Cheers, Manuel

Re: updating file

2000-04-28 Thread Jan Skibinski
On Fri, 28 Apr 2000, Fergus Henderson wrote: > > > > This is all fine and dandy if `currentSecond' is within `where' > > clause, because it will be always evaluated afresh. > > It might happen to work with current Haskell implementations, > but I don't think there's any guarantee of t

Fw: doubly linked list

2000-04-28 Thread Jan Brosius
> Jerzy Karczmarczuk wrote: > > Yes, Simula-67. > > Actually *they did* that. A "node" had two sub-classes, the link and the > head, and the link chain was doubly attached to the head. This structure > has been havily used for the maintenance of the co-routine bedlam > exploited in si

RE: updating file

2000-04-28 Thread Jan Skibinski
Erik: > You have discovered the essence of monads, ie the difference between the bad > and ugly world of side-effecting computations and the nice and clean world > of pure functions. And even using my favourite example (*)! Let's put it in other words: I knew the difference,

Re: doubly linked list

2000-04-28 Thread Peter Hancock
> "Jerzy" == Jerzy Karczmarczuk <[EMAIL PROTECTED]> writes: > The idea of double lists was to permit a fast two-directional > navigation, > and the ease of insertion/deletion. > But in Haskell, where the beasts are not mutable: > ... Actually, has anybody really used the

Re: doubly linked list

2000-04-28 Thread Marc van Dongen
Jerzy Karczmarczuk ([EMAIL PROTECTED]) wrote: : But in Haskell, where the beasts are not mutable: : : ... Actually, has anybody really used them for practical purposes? I have used doubly linked lists in Haskell about four years ago to implement a queue from which objects could be added at fron

Re: doubly linked list

2000-04-28 Thread Jerzy Karczmarczuk
Chris Angus: > > Would it not be better to tag a start point then we can manipulate this > easier > and move it back to a singly linked list etc. > > data Db a = Dd (Db a) a (Db a) > | DStart (Db a) a (Db a) > > ... Well, I am sufficiently old to confess that one of my favourite OO l

RE: doubly linked list

2000-04-28 Thread Chris Angus
Would it not be better to tag a start point then we can manipulate this easier and move it back to a singly linked list etc. data Db a = Dd (Db a) a (Db a) | DStart (Db a) a (Db a) instance Show a => Show (Db a) where show xs = show (enumerate xs) instance Eq

RE: doubly linked list

2000-04-28 Thread Chris Angus
> -Original Message- > From: Peter Hancock [mailto:[EMAIL PROTECTED]] > Sent: 28 April 2000 10:23 > To: [EMAIL PROTECTED] > Cc: [EMAIL PROTECTED] > Subject: Re: doubly linked list > > > > "Jan" == Jan Kort <[EMAIL PROTECTED]> writes: > > > Anyway, a doubly linked list could be

Re: doubly linked list

2000-04-28 Thread Peter Hancock
> "Jan" == Jan Kort <[EMAIL PROTECTED]> writes: > Anyway, a doubly linked list could be defined like this: That was very interesting. It seems to generalise to put back-pointers and other context info in a variety of data structures. This seems a pretty performance-enhancing thing to do

Re: doubly linked list

2000-04-28 Thread Jerzy Karczmarczuk
> Jan Brosius wrote: > I wonder if it is possible to simulate a doubly linked list in > Haskell. ... and the number of answers was impressive... Want some more? This is a short for *making* true double lists, and as an extra bonus it is circular. Slightly longer than the solution of Jan Kort, n

RE: updating file

2000-04-28 Thread Nigel Perry
At 11:00 am +0200 28/4/00, Erik Meijer wrote: >If you want to play it rough, you could do what ML programmers do and >explicitely delay and force the computation of currentSecond: > > currentSecond :: () -> Int > currentSecond () = second $ unsafePerformIO localDateTime > >However, you should

RE: updating file

2000-04-28 Thread Erik Meijer
> currentSecond = second $ unsafePerformIO localDateTime > > where `localDateTime' has been defined via primitive > call to C: > > localDateTime :: IO DateTime > > To my distress the clock stopped after the first call to > `currentSecond'. I took me much more than