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 -
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 .
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
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
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
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
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]
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
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
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
Apologies if you receive multiple copies...
CALL FOR PAPERS
ACM SIGPLAN
WAAAPL 2002
[Deadline for
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
Ç×°®µÄÅóÓÑ£ºÐÂÄêºÃ£¡
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
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
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-
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
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
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
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
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)
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
Title: RE: String manipulation.
Thank you very much I'll try both
approaches.
Regards, Dimitris
Keramidas
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]] -
Hi
Question:
For what reason we need the "Type
inference" if we can enforce "Type constraints" ?
Thanks in
advance.
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
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
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
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
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
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
30 matches
Mail list logo