Re: Reference types

2002-02-07 Thread Ashley Yakeley
At 2002-02-05 16:54, I wrote: data Ref m a = MkRef { get :: m a, set :: a - m (), modify :: (a - a) - m () }; Better, data Ref m a = MkRef { get :: m a, set :: a - m () }; modify :: (Monad m) = Ref m a - (a -

Re: Reference types

2002-02-07 Thread Ashley Yakeley
At 2002-02-07 00:52, John Hughes wrote: Hmm. Yes. But you still haven't addressed dropping references created in the transformed monad back into the underlying one again. Oh that's easy: liftedNewSTRef :: (LiftedMonad (ST s) m) = a - m (Ref (ST s) a); liftedNewSTRef = lift .

RE: Reference types

2002-02-07 Thread Simon Peyton-Jones
Wow. One innocent message... | Oh no, please don't do this! I use the RefMonad class, but | *without* the dependency r - m. Why not? Because I want to | manipulate (for example) STRefs in monads built on top of the | ST monad via monad transformers. So I use the same reference | type with

RE: Reference types

2002-02-07 Thread Ashley Yakeley
At 2002-02-07 01:19, Simon Peyton-Jones wrote: 1. Have a single built-in type (Ref), rather than two (IORef and STRef). I don't see how that can be anything other than a Good Thing, can it? The problem is that your Ref type is primitive, which means users wouldn't be able to create their own

RE: Reference types

2002-02-07 Thread John Hughes
Simon writes: There were really two parts to my message: 1. Have a single built-in type (Ref), rather than two (IORef and STRef). I don't see how that can be anything other than a Good Thing, can it? The primitive operations over Refs are still

RE: Reference types

2002-02-07 Thread Ashley Yakeley
At 2002-02-07 02:09, I wrote: The kind of generalisation you are proposing is, in my opinion, best done explicitly by Haskell. Primitive functions and types should be as simple, concrete and primitive as possible. Let Haskell do the clever generalisation stuff. As a rule, I'm opposed to any

Re: Position of arguments in function definition and performance

2002-02-07 Thread José Romildo Malaquias
The programs: -- common part module Main where reverse1 [] ys = ys reverse1 (x:xs) ys = reverse1 xs (x:ys) reverse2 ys [] = ys reverse2 ys (x:xs) = reverse2 (x:ys) xs -- program t1 main = print (length $! reverse1 [1..200]

ST and IO. Two problems. Some old some new?

2002-02-07 Thread Amr Sabry
Background. We have two notions of state (ST and IO) with two mediating operations: unsafeIOtoST :: IO a - ST s a stToIO :: ST s a - IO a unsafeIOtoST is documented as unsafe because exceptions that would have been caught in the IO monad are not caught in the ST monad but this is irrelevant to

Re: ST and IO. Two problems. Some old some new?

2002-02-07 Thread Koen Claessen
Amr Sabry wrote: | unsafeIOtoST is documented as unsafe because | exceptions that would have been caught in the IO monad | are not caught in the ST monad but this is irrelevant | to the rest of the message. I think it is unsafe because *all* IO-type side effects (not only exceptions but

Re: ST and IO. Two problems. Some old some new?

2002-02-07 Thread Ross Paterson
On Thu, Feb 07, 2002 at 12:41:50PM +0100, Koen Claessen wrote: Amr Sabry wrote: | 2. Soundness of stToIO : | data Var a = Var { get :: () - IO a, |set :: a - IO ()} (Why does get have this type?) [...] The type of stToIO is: stToIO :: ST RealWorld a - IO

WAAAPL 2002, call for papers

2002-02-07 Thread Okasaki, C. DR EECS
Apologies if you receive multiple copies... CALL FOR PAPERS ACM SIGPLAN WAAAPL 2002 [Deadline for

haskell@haskell.org

2002-02-07 Thread º×±Ú»·ÑàÂÖÌ¥ÓÐÏÞ¹«Ë¾
Title: Happy New Year! ¡¡ Dear Sirs/Madams,Happy New Year!This is a nice E-greeting from China Hebi Huanyan Tyre Co.,Ltd. Go and pick it up at£ºhttp://www.huanyan.com.cn/newyear.htm Ç×°®µÄÅóÓÑ£ºÐÂÄêºÃ£¡

String manipulation.

2002-02-07 Thread DK
Hello. First of all I am a beginner in Haskell, and I must confess I do not yet fully understand it. I need to write a program in Haskell, though, and I am having some difficulties... What I would like to ask, is how can I take a string from a list, and manipulate it, in order to convert

Re: String manipulation.

2002-02-07 Thread Hal Daume III
You should have a look at the Read class. A member a of the Read class has a function read :: String - a. so, for example, you can say: (read 5.0) :: Double to read this as a double. You could also read it as an integer or something. If you have a list of strings that you want to convert

RE: String manipulation.

2002-02-07 Thread Chris Angus
Title: RE: String manipulation. You may want to use reads as read will call error if the string is not an integer or use something akin to the example below readMaybeInt :: String - Maybe Int readMaybeInt s = case reads s of [(x,_)] - Just x _ - Nothing -Original Message-

layout rules for where

2002-02-07 Thread Zhanyong Wan
Hi, I have been a big fan of Haskell's layout rules, but was got by them lately. Here's what I was doing. I wrote something like: foo = ... where bar = ... ... -- 600 lines of Haskell code suppressed baz = ... Unsurprisingly, when I load this module in Hugs, I can use baz as

Re: layout rules for where

2002-02-07 Thread Malcolm Wallace
Can't we require that a local definition be more indented than the enclosing definition? It is required in Haskell'98. You have stumbled on a bug in Hugs, which you should report to the maintainers. Regards, Malcolm ___ Haskell mailing list

Re: layout rules for where

2002-02-07 Thread Ian Zimmerman
Zhanyong I was lucky to spot the source of the problem quickly Zhanyong because I knew I recently changed that line, but in general, Zhanyong this kind of error can be very hard to locate. (In my case, Zhanyong the offending code is 600 lines away from where the bug is Zhanyong manifested, and

(no subject)

2002-02-07 Thread Phil Haymen
hi,how do I define a function to test whether a number is an element of a list of lists of numbers. elem :: Int - [[Int]] - Bool __ Do You Yahoo!? Send FREE Valentine eCards with Yahoo! Greetings! http://greetings.yahoo.com

RE: (no subject)

2002-02-07 Thread Konst Sushenko
One way to do it would be to look at the prelude's elem function. Otherwise, just scan each list until you find a match. -Original Message- From: Phil Haymen [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 07, 2002 12:18 PM To: [EMAIL PROTECTED] Subject: (no subject)

Re: (no subject)

2002-02-07 Thread bracaman
If you can use elem :: Eq a = a - [a] - Bool function, you can do: f x l= or (map (elem x) l On Thursday 07 February 2002 20:17, you wrote: hi,how do I define a function to test whether a number is an element of a list of lists of numbers. elem :: Int - [[Int]] - Bool

Re: String manipulation.

2002-02-07 Thread DK
Title: RE: String manipulation. Thank you very much I'll try both approaches. Regards, Dimitris Keramidas

Re: (no subject)

2002-02-07 Thread Zhanyong Wan
bracaman wrote: If you can use elem :: Eq a = a - [a] - Bool function, you can do: f x l= or (map (elem x) l On Thursday 07 February 2002 20:17, you wrote: hi,how do I define a function to test whether a number is an element of a list of lists of numbers. elem :: Int - [[Int]] -

type inference

2002-02-07 Thread ilje
Hi Question: For what reason we need the "Type inference" if we can enforce "Type constraints" ? Thanks in advance.

Re: character syntax

2002-02-07 Thread Jesper Louis Andersen
On Thu, Feb 07, 2002 at 08:00:36AM -0800, Ian Zimmerman wrote: I am new to the language (coming from ML) and I am sorry if my first post turns out to be a flamebait, but I can't help it: Why in the world did the designers of Haskell permit the ' character to be both a prime (part of

Re: character syntax

2002-02-07 Thread Jesper Louis Andersen
On Thu, Feb 07, 2002 at 08:38:22AM -0800, Ian Zimmerman wrote: You miss my point: I agree that having a prime character for id's is neat. But in SML, that's the _only_ role it has, character literals are written like #x. With Haskell's characters (and Ocaml's :-( ) Ooops, yup... I forgot

Re: character syntax

2002-02-07 Thread Ian Zimmerman
Hal Since we're on this topic, I'm constantly annoyed by the Hal following (in addition to sexps with '(' and ')'): how to get Hal emacs to realize that it should match the parens on: Hal map (\(x,y) - ... Hal since \( isn't an escape character. i end up writing: Hal map (\ (x,y) - ... Hal

Re: character syntax

2002-02-07 Thread Jon Fairbairn
All this taken together, I mean, _really_, is the lexical structure of Haskell a botch, or what? No. Innovative. All the problems described in this thread reflect unwarranted assumptions inherited in emacs. It's plainly possible to parse Haskell, and not hard either. Jón -- Jón

Re: character syntax

2002-02-07 Thread Ian Zimmerman
brian If you think about languages that have been designed to be easy brian to parse, are these really languages that you would want to brian use? No, but for different (semantical) reasons. -- Ian Zimmerman, Oakland, California, U.S.A. GPG: 433BA087 9C0F 194F 203A 63F7 B1B8 6E5A 8CA3 27DB

Re: character syntax

2002-02-07 Thread D. Tweed
On 7 Feb 2002, Ian Zimmerman wrote: itz All this taken together, I mean, _really_, is the lexical itz structure of Haskell a botch, or what? Jon No. Innovative. All the problems described in this thread reflect Jon unwarranted assumptions inherited in emacs. It's plainly possible Jon to