[Haskell-cafe] evaluate vs seq

2006-09-09 Thread Michael Shulman
The GHC documentation says that (evaluate a) is not the same as (a `seq` return a). Can someone explain the difference to me, or point me to a place where it is explained? Mike ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.o

Re: [Haskell-cafe] nondet function

2006-09-09 Thread Tom Phoenix
On 9/9/06, Ashley Yakeley <[EMAIL PROTECTED]> wrote: Is it possible to write nondet? Yes; it (or something very similar) is discussed here: http://www.haskell.org/haskellwiki/Timing_out_computations Hope this helps! --Tom Phoenix ___ Haskell-Ca

[Haskell-cafe] nondet function

2006-09-09 Thread Ashley Yakeley
Is it possible to write nondet? nondet :: a -> a -> a nondet _|_ _|_ = _|_ nondet _|_ q = q nondet p _|_ = p nondet p q = p or q nondet evaluates its arguments in parallel, and returns the first one of them to evaluate. It's thus a bit different from the "par" of GPH. This isn't refe

[Haskell-cafe] Re: map (-2) [1..5]

2006-09-09 Thread Aaron Denney
On 2006-09-09, Jón Fairbairn <[EMAIL PROTECTED]> wrote: > Aaron Denney <[EMAIL PROTECTED]> writes: >> Meh. Naturals are reasonably useful sometimes, but not often enough, in >> my opinion. Any sort of numeric hierarchy designed to deal with them >> would be totally broken from my point of view -

Re: [Haskell-cafe] Slow IO

2006-09-09 Thread jeff p
Hello, Try Don Stewart's ByteString library (http://www.cse.unsw.edu.au/~dons/fps.html). It is much faster than the standard Haskell IO and now has lazy. -Jeff On 9/9/06, Daniel Fischer <[EMAIL PROTECTED]> wrote: Hello all, Now I have an IO-problem, too. SPOJ problem 41 asks basically to dete

[Haskell-cafe] Slow IO

2006-09-09 Thread Daniel Fischer
Hello all, Now I have an IO-problem, too. SPOJ problem 41 asks basically to determine whether a directed graph allows a path that uses every edge exactly once. The data from which the graphs are to be constructed are contained in a (huge) file, every item (number of test cases, size of test case

[Haskell-cafe] Re: NaN, Infinity literals

2006-09-09 Thread Arie Peterson
Ashley Yakeley wrote: > Bertram Felgenhauer wrote: > >> This is correct according to the IEEE 754 standard, which defines >> that NaN compares unequal to everything, including itself. > > This is numerically useful, perhaps, but nonetheless disturbing. For it > would be helpful to expect that any

[Haskell-cafe] Weak pointers and referential transparency???

2006-09-09 Thread Brian Hulley
Hi, I have the following data structures: import System.Mem.Weak data Proxy = ... data Model = Model { _proxiesRef :: !(Ref.T [Weak Proxy]), ...} (Ref.T is just a lifted IORef) I was writing code like: createProxy :: MonadIO m => Model -> m Proxy createProxy Model{_proxiesRef =

Re: [Haskell-cafe] How to round off frational number?

2006-09-09 Thread Sara Kenedy
Thanks a lot. That's what I need. On 9/8/06, J. Garrett Morris <[EMAIL PROTECTED]> wrote: I've always used: roundn n f = fromIntegral (round (f * 10 ^ n)) / 10 ^ n I may have missed some bugs or subtleties of floating point numbers, though. /g On 9/8/06, Sara Kenedy <[EMAIL PROTECTED]> wrot

Re: [Haskell-cafe] Re: sections of noncommutative operators

2006-09-09 Thread Michael Shulman
On 9/9/06, Brian Hulley <[EMAIL PROTECTED]> wrote: Yes: tuples, contexts, set of classes to derive from in a deriving clause, module export list, import directives. I guess I thought of most of those as a sort of grouping, without really thinking about it. But I suppose you are right that they

Re: [Haskell-cafe] Re: sections of noncommutative operators

2006-09-09 Thread Brian Hulley
Michael Shulman wrote: On 09 Sep 2006 11:17:52 +0100, Jón Fairbairn <[EMAIL PROTECTED]> wrote: Right about the start of the design of Haskell, I proposed the rule "parentheses should only be used for grouping". I think I would have liked that rule. Are parentheses currently used for anything

Re: [Haskell-cafe] Re: map (-2) [1..5]

2006-09-09 Thread Brian Hulley
Jón Fairbairn wrote: "Brian Hulley" <[EMAIL PROTECTED]> writes: I imagine that almost every editor at least does lexical fontification, and if so, then I don't think there could be much confusion in practice between these uses of '-'. I think that unnecessarily disadvantages people with poorer

Re: [Haskell-cafe] Re: sections of noncommutative operators

2006-09-09 Thread Michael Shulman
No, lisp doesn't have currying, but of course I knew that Haskell does. I think my thought processes went something like this: I want to partially apply "<", but < is an infix operator in Haskell, so first I have to convert it to the function (<) written with prefix notation and then partially ap

Re: [Haskell-cafe] Re: sections of noncommutative operators

2006-09-09 Thread Bill Wood
On Sat, 2006-09-09 at 11:17 +0100, Jón Fairbairn wrote: . . . > I should think so. But does lisp have currying these days? > (lessp 0 1) ==> T > but (lessp 0) would be an error, wouldn't it? For Scheme, R5RS, Section 6.2.5 specifies that "<" and ">" take two or more arguments, and PLT Scheme r

Re: [Haskell-cafe] HaXml and ghci unresolved symbol

2006-09-09 Thread Andrea Rossato
Il Sat, Sep 09, 2006 at 09:58:03AM -0700, Jason Dagit ebbe a scrivere: > Maybe "...use -package HaXml interactively with GHCi..." (That's from > the HaXml website.) I'm using "-package HaXml", obviously, otherwise the module would not load. What I do not understand is that "unresolved symbol" mes

Re: [Haskell-cafe] HaXml and ghci unresolved symbol

2006-09-09 Thread Jason Dagit
On 9/9/06, Andrea Rossato <[EMAIL PROTECTED]> wrote: Hello! [snip] During interactive linking, GHCi couldn't find the following symbol: TextziXMLziHaXmlziParse_xmlParse_closure This may be due to you not asking GHCi to load extra object files, archives or DLLs needed by your current session.

Re: [Haskell-cafe] HaXml and ghci unresolved symbol

2006-09-09 Thread Bulat Ziganshin
Hello Andrea, Saturday, September 9, 2006, 4:17:36 PM, you wrote: > During interactive linking, GHCi couldn't find the following symbol: > TextziXMLziHaXmlziParse_xmlParse_closure as a workaround, you can try to run your program using runghc and compile it using "ghc --make" -- Best regards,

Re: [Haskell-cafe] Derived Read instance for types with infix constructors (ghc 6.4.1)

2006-09-09 Thread Misha Aizatulin
Daniel Fischer wrote: > Another thing: > Would it be a good idea to create derived Read instances that could parse > both, "A `And` A" and "And A A" ? > Since 6.4.2 parses the former and 6.2.2 parses the latter that should be > possible, I believe (and both forms are accepted at the ghci prompt)

[Haskell-cafe] Re: map (-2) [1..5]

2006-09-09 Thread Jón Fairbairn
"Brian Hulley" <[EMAIL PROTECTED]> writes: > Jón Fairbairn wrote: > > [1] “-” is a varsym. The logical way of achieving what you > > suggest (ie -1 -2... as constructors for Integer) would be > > to make it introduce a consym the way “:” does, but then it > > couldn't be an infix operator anymore.

[Haskell-cafe] Re: map (-2) [1..5]

2006-09-09 Thread Jón Fairbairn
Aaron Denney <[EMAIL PROTECTED]> writes: > On 2006-09-08, Jón Fairbairn <[EMAIL PROTECTED]> wrote: > > Why shouldn't Naturals be more primitive than Integers? > > Certainly they're more primitive. Too primitive to have reasonable > algebraic properties. Hmph. Naturals obey (a+b)+c == a+(b+c),

[Haskell-cafe] Re: map (-2) [1..5]

2006-09-09 Thread Jón Fairbairn
Aaron Denney <[EMAIL PROTECTED]> writes: > Jón Fairbairn <[EMAIL PROTECTED]> wrote: > > I think the present design is wrong because we don't have a > > type for naturals. > > Meh. Naturals are reasonably useful sometimes, but not often enough, in > my opinion. Any sort of numeric hierarchy des

[Haskell-cafe] Re: map (-2) [1..5]

2006-09-09 Thread Jón Fairbairn
Aaron Denney <[EMAIL PROTECTED]> writes: > We already have this great syntax, parsing semanticsi for precedence, > and so forth for declaring infix operators. Couldn't we add to that > slightly by declaring postfix operators as well? Actually, declaring a > unary operator infix yielding a postfi

[Haskell-cafe] Re: map (-2) [1..5]

2006-09-09 Thread Aaron Denney
On 2006-09-08, Brian Hulley <[EMAIL PROTECTED]> wrote: > Leaving aside the question of negative literals for the moment, what's so > special about unary minus that it warrants a special syntax? For example in > mathematics we have x! to represent (factorial x), which is also an > important funct

[Haskell-cafe] Re: map (-2) [1..5]

2006-09-09 Thread Aaron Denney
On 2006-09-08, Jón Fairbairn <[EMAIL PROTECTED]> wrote: > "Brian Hulley" <[EMAIL PROTECTED]> writes: >> In the context of programming, I don't see the problem of >> just thinking of the integers as a primitive built-in data >> type which contains some range of positive and negative >> integers whi

[Haskell-cafe] Re: map (-2) [1..5]

2006-09-09 Thread Aaron Denney
"Cale Gibbard" <[EMAIL PROTECTED]> writes: > Another thing to note is that all the natural literals are not, as one > might initially think, plain values, but actually represent the > embedding of that natural number into the ring (instance of Num), by > way of 0 and 1. Excellent point, and good

Re: [Haskell-cafe] Re: map (-2) [1..5]

2006-09-09 Thread Ross Paterson
On Sat, Sep 09, 2006 at 12:57:56AM -0400, Cale Gibbard wrote: > Num itself needs to be split, but we can't do it sanely without > something like class aliases. I think that a finer grain numeric hierarchy, while retaining Num, etc, is feasible without changing the language: unlike the case of mona

[Haskell-cafe] HaXml and ghci unresolved symbol

2006-09-09 Thread Andrea Rossato
Hello! probably it's me, but I cannot understand what I'm doing wrong. I'm trying to learn HaXml. I've never used it before and I never did xml processing in Haskell. So I'm a total newbie!! I downloaded and compiled. Everything seems fine. I'm also able to run some examples in the related direc

[Haskell-cafe] Re: sections of noncommutative operators

2006-09-09 Thread Jón Fairbairn
"Michael Shulman" <[EMAIL PROTECTED]> writes: > A propos of sections of subtraction, and thence to sections of other > noncommutative operators, as a Haskell newbie I was surprised to > discover (the hard way!) that > > (< 0) > > and > > ((<) 0) > > mean different things. I had typed (< 0) wh

Re: [Haskell-cafe] Re: map (-2) [1..5]

2006-09-09 Thread David House
On 09/09/06, Cale Gibbard <[EMAIL PROTECTED]> wrote: When I first ran into the problem with (-) and sections, I was slightly annoyed with having to write (+ (-1)) Let's not forget that there is the library function 'subtract' for this purpose. What you wrote could be written as (subtract 1), wh

Re: [Haskell-cafe] [Newbie] Cannot derive Eq and Show. Why?

2006-09-09 Thread Bulat Ziganshin
Hello Peter, Friday, September 8, 2006, 6:03:36 PM, you wrote: > I am stumped again. The following code generates the error "ERROR > file:.\Cube.hs:12 - An instance of IArray UArray a is required to derive Eq > (Cube a b)" in Hugs. But I did specify the IArray UArray k constraint. So > what is wr

[Haskell-cafe] sections of noncommutative operators

2006-09-09 Thread Michael Shulman
A propos of sections of subtraction, and thence to sections of other noncommutative operators, as a Haskell newbie I was surprised to discover (the hard way!) that (< 0) and ((<) 0) mean different things. I had typed (< 0) when I meant to type ((<) 0). No compiler errors, of course, and I ha