RE: [Haskell-cafe] Template Haskell, information about data constructor types

2007-06-04 Thread Simon Peyton-Jones
| Where typeApp splits a type to find its constructor, ctorTypes gets | the types of the fields, and dataCtors gets the constructors in a data | type. Unfortunately reify doesn't seem to work on types. Is it | possible to do what I am after? reify takes a Name, not a Type. Perhaps you mean that

[Haskell-cafe] Re: Why does the class called Real support only rationals, and not all reals?

2007-06-04 Thread DavidA
Yes, I'm afraid that you are understanding correctly. Annoying isn't it. It is well-known (among Haskell mathematicians at least) that the numeric type classes in the prelude are broken. Here's one proposal for a small step in the right direction:

Re: [Haskell-cafe] Template Haskell, information about data constructor types

2007-06-04 Thread Neil Mitchell
Hi Simon, On 6/4/07, Simon Peyton-Jones [EMAIL PROTECTED] wrote: | Where typeApp splits a type to find its constructor, ctorTypes gets | the types of the fields, and dataCtors gets the constructors in a data | type. Unfortunately reify doesn't seem to work on types. Is it | possible to do what

RE: [Haskell-cafe] Failure in GHC compilation

2007-06-04 Thread Simon Peyton-Jones
I've extended the what to look for if your build fails section in http://hackage.haskell.org/trac/ghc/wiki/Building/Windows Please do keep adding to this page! Every time you trip over something, think about whether your experience could be used to help someone else. Simon |

RE: [Haskell-cafe] RE: [Haskell] boilerplate boilerplate

2007-06-04 Thread Simon Peyton-Jones
| lot of elements in it. Having to do an explicit declaration of deriving | (Data,Typeable) for each of them is just a tremendous beat-down no | matter where I do it. I hate to see you beaten down, Alex. Make a feature request. I don't want to make promises, but having a well-specified

Re: [Haskell-cafe] RE: [Haskell] boilerplate boilerplate

2007-06-04 Thread Neil Mitchell
Hi On 6/1/07, Alex Jacobson [EMAIL PROTECTED] wrote: I suppose a deriveAll command from template haskell would work. Is that really possible? Asking people who have more knowledge of template haskell, I'm still not sure. What it would really rely on is: getDataDeclarationsInCurrentModule

Re: [Haskell-cafe] Optimising UTF8-CString - String marshaling, plus comments on withCStringLen/peekCStringLen

2007-06-04 Thread Duncan Coutts
On Mon, 2007-06-04 at 09:43 +0100, Alistair Bayley wrote: After some expriments with the simplifier, I think I have a portable version of a direct-from-buffer decoder which seems to perform nearly as well as one written directly against GHC primitive unboxed functions. I'm wondering if

Re[2]: [Haskell-cafe] Optimising UTF8-CString - String marshaling, plus comments on withCStringLen/peekCStringLen

2007-06-04 Thread Bulat Ziganshin
Hello Duncan, Monday, June 4, 2007, 2:25:10 PM, you wrote: - the chr function tests that its Int argument is less than 1114111, before constructing the Char. It'd be nice to avoid this test. use unsafeChr or, for portability, smth like this: #ifdef GHC import GHC.Exts (unsafeChr) #else

[Haskell-cafe] Re: enumFrom* strangeness on GHC?

2007-06-04 Thread Simon Marlow
Felipe Almeida Lessa wrote: On 5/31/07, Stefan O'Rear [EMAIL PROTECTED] wrote: You don't need to feel too bad about this: [snip] Don't worry, I should have googled anyway =). BTW, how do you usually proceed when finding out why your code said Segmentation fault.? (should this question move

[Haskell-cafe] Re: small hack on hasktags to make it collect class names

2007-06-04 Thread Simon Marlow
Marc Weber wrote: You can download the modified version from http://mawercer.de/marcweber/hasktags.hs care to send us a patch? Cheers, Simon ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

Re: [Haskell-cafe] RE: [Haskell] boilerplate boilerplate

2007-06-04 Thread Claus Reinke
I suppose a deriveAll command from template haskell would work. Is that really possible? Asking people who have more knowledge of template haskell, I'm still not sure. What it would really rely on is: getDataDeclarationsInCurrentModule :: Q [Dec] Whether that can be done or not is still not

Re: [Haskell-cafe] Optimising UTF8-CString - String marshaling, plus comments on withCStringLen/peekCStringLen

2007-06-04 Thread Alistair Bayley
On 04/06/07, Duncan Coutts [EMAIL PROTECTED] wrote: On Mon, 2007-06-04 at 09:43 +0100, Alistair Bayley wrote: After some experiments with the simplifier, ... The portable unboxed version is within about 15% of the unboxed version in terms of time and allocation. Well done. Of course, that

Re: [Haskell-cafe] Optimising UTF8-CString - String marshaling, plus comments on withCStringLen/peekCStringLen

2007-06-04 Thread Duncan Coutts
On Mon, 2007-06-04 at 13:12 +0100, Alistair Bayley wrote: BTW, what's the difference between the indexXxxxOffAddr# and readXxxxOffAddr# functions in GHC.Prim? Right. So it'd only be safe to use the index ones on immutable arrays because there's no way to enforce sequencing with

[Haskell-cafe] Idiomatically using lists

2007-06-04 Thread kevin birch
Hello all, I have an implementation question that I hope someone can help out with. Say I have a fixed-size list: [1, 2, 3, 4, 5] that I want to treat as circular in a function in order to rotate one of the elements n positions. So rotating the second element 2 positions would result

Re: [Haskell-cafe] Why does the class called Real support only rationals, and not all reals?

2007-06-04 Thread Henning Thielemann
On Sun, 3 Jun 2007, bretm wrote: I just got started learning Haskell a few days ago. I've implemented a numeric data type that can represent some irrational numbers exactly, and I'd like to instantiate the RealFrac class so I can do truncate, round, etc., in the most natural way in the

[Haskell-cafe] newbie question on Parsers from Programming In Haskell

2007-06-04 Thread Juozas Gaigalas
Hello, I am a somewhat experienced programmer and a complete Haskell newbie, so I hope this is the correct ML for my question. I have decided to learn Haskell and started with Graham Hutton's book. Everything was going nicely until section 8.4, on sequencing functional parsers. I am trying to

Re: [Haskell-cafe] newbie question on Parsers from Programming In Haskell

2007-06-04 Thread Alfonso Acosta
On 6/4/07, Juozas Gaigalas [EMAIL PROTECTED] wrote: Hello, I am a somewhat experienced programmer and a complete Haskell newbie, so I hope this is the correct ML for my question. I have decided to learn Haskell and started with Graham Hutton's book. Everything was going nicely until section

Re: [Haskell-cafe] newbie question on Parsers from Programming In Haskell

2007-06-04 Thread David House
On 04/06/07, Alfonso Acosta [EMAIL PROTECTED] wrote: Hugs is probably complaining because it identifies x - item (which is not a simple expression) as the last element of do. That was my first guess, too, but it's not the case, switch to a monospaced font to see this. Juozas, you could only

Re: [Haskell-cafe] newbie question on Parsers from Programming In Haskell

2007-06-04 Thread C.M.Brown
Hi Juozas, - type Parser a = String - [(a, String)] return :: a - Parser a return v = \inp - [(v, inp)] failure :: Parser a failure = \inp - [] item :: Parser Char item = \inp - case inp of [] - [] (x:xs) - [(x, xs)] parse

Fwd: [Haskell-cafe] Optimising UTF8-CString - String marshaling, plus comments on withCStringLen/peekCStringLen

2007-06-04 Thread Alistair Bayley
(this time include the list, too) -- Forwarded message -- From: Alistair Bayley [EMAIL PROTECTED] Date: 04-Jun-2007 16:13 Subject: Re: [Haskell-cafe] Optimising UTF8-CString - String marshaling, plus comments on withCStringLen/peekCStringLen To: Duncan Coutts [EMAIL PROTECTED]

Re: [Haskell-cafe] Why does the class called Real support only rationals, and not all reals?

2007-06-04 Thread bretm
Awesomely complete response. Thank you. Henning Thielemann wrote: There are several things that are inconvenient in the numeric part of Haskell 98 Prelude. As always I suggest a look at alternative numeric class hierarchies, like NumericPrelude:

Re: [Haskell-cafe] Why does the class called Real support only rationals, and not all reals?

2007-06-04 Thread bretm
DavidA-2 wrote: Yes, I'm afraid that you are understanding correctly. Annoying isn't it. It is well-known (among Haskell mathematicians at least) that the numeric type classes in the prelude are broken. Here's one proposal for a small step in the right direction:

Re: [Haskell-cafe] Why does the class called Real support only rationals, and not all reals?

2007-06-04 Thread Henning Thielemann
On Mon, 4 Jun 2007, bretm wrote: Henning Thielemann wrote: Is your approach more like symbolic calculation or more like a representation for computable reals? http://www.haskell.org/haskellwiki/Applications_and_libraries/Mathematics#Number_representations Computable reals,

[Haskell-cafe] Re: Hardware

2007-06-04 Thread Al Falloon
Bulat Ziganshin wrote: it seems that now we move right into this direction with GPUs I was just thinking that GPUs might make a good target for a reduction language like Haskell. They are hugely parallel, and they have the commercial momentum to keep them current. It also occurred to me that

Re: [Haskell-cafe] Re: Why does the class called Real support only rationals, and not all reals?

2007-06-04 Thread Dan Piponi
On 6/4/07, DavidA [EMAIL PROTECTED] wrote: Yes, I'm afraid that you are understanding correctly. Annoying isn't it. It is well-known (among Haskell mathematicians at least) that the numeric type classes in the prelude are broken. A few days ago I found myself forced to write: instance

Re: [Haskell-cafe] newbie question on Parsers from Programming In Haskell

2007-06-04 Thread Dan Weston
David House wrote: Juozas, you could only use do-notation if your Parser type were declared an instance of the Haskell type-class Monad. Seeing as you haven't done this, you have to stick to the de-sugared version involving (=) and return: Is this true? I thought do (like all sugar) was

Re: [Haskell-cafe] Idiomatically using lists

2007-06-04 Thread Dan Weston
I would think a simple cyclic list should work without any copying at all: rotateList myList n = take m . drop n $ x where x = myList ++ x m = length myList Just keep dropping elements to rotate. A possible alternative is to use a more tailored data structure with a zipper. See

Re: [Haskell-cafe] newbie question on Parsers from Programming In Haskell

2007-06-04 Thread Albert Y. C. Lai
Dan Weston wrote: Is this true? I thought do (like all sugar) was desugared before semantic analysis. So long as you have the right =, return, and fail in scope, I would have thought the desugaring is oblivious to their definition (and particularly ignorant of instancing of the Monad

Re: [Haskell-cafe] Re: Has anyone looked into adding subtyping...

2007-06-04 Thread Jason Dagit
On 6/2/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: The last time I tried this code, I reported to haskell-cafe that OOHaskell does not work when compiled as a library (at least under GHC). For some reason the code that uses OOHaskell had to be compiled along side it. Is this now fixed?

Re: [Haskell-cafe] What puts False before True?

2007-06-04 Thread Scott Brickner
All these smart math guys hanging around and nobody's given a really decent answer to this? It's actually not arbitrary. There's a strong connection between predicates (functions that return boolean values) and sets. Any predicate uniquely determines a set - the set of values for which it

[Haskell-cafe] How to read -ddump-hi output (and other phases) from GHC

2007-06-04 Thread Alistair Bayley
I'm collecting links to documents describing some of GHC's optimisation output flags, like -ddump-hi and -ddump-simpl. I'll add stuff to this wiki page: http://www.haskell.org/haskellwiki/Performance/GHC So far I've found little bits in the GHC manual, like: 4.16.3. How to read Core syntax

Re: [Haskell-cafe] How to read -ddump-hi output (and other phases) from GHC

2007-06-04 Thread Neil Mitchell
Hi 4.16.3. How to read Core syntax http://www.haskell.org/ghc/docs/latest/html/users_guide/options-debugging.html#id3130643 I found that -ddump-simpl gives you good information, in a readable form - I much prefer it to reading the .hcr files. Thanks Neil

Re: [Haskell-cafe] Re: I just don't get it (data structures and OO)

2007-06-04 Thread David Menendez
Arie Peterson writes: There are two things one typically wants to do when working with a substructure of some larger data structure: (1) extract the substructure; and (2) change the larger structure by acting on the substructure. A 'Ref cx t' encodes both of these functions (for a

Re: [Haskell-cafe] Idiomatically using lists

2007-06-04 Thread kevin birch
On 火, 2007-6月-05, at 02:54, Greg Fitzgerald wrote: rotating the fourth element 2 positions would result in: [1, 2, 4, 3, 5] Seems odd. Should that be [4,1,2,3,5]? Yes, I meant to use the 5 element in my second example. Sorry for the confusion. Is there an idomatic way to handle both

Re: [Haskell-cafe] Re: I just don't get it (data structures and OO)

2007-06-04 Thread Claus Reinke
| data Ref cx t | = Ref | { | select :: cx - t | , update :: (t - t) - cx - cx | } | | A Ref is a bit like a typed and composable incarnation of apfelmus's | indices, or a wrapper around Tillmann's change* functions, containing | not only a setter but also the accompanying

[Haskell-cafe] Java Monads?

2007-06-04 Thread Greg Meredith
HaskellyCaffeinated, i noticed that there was a JavaMonad lib kicking around on the web, but all the links i can find are stale. Does anybody have a live pointer to this lib? Best wishes, --greg -- L.G. Meredith Managing Partner Biosimilarity LLC 505 N 72nd St Seattle, WA 98103 +1

[Haskell-cafe] Re: I just don't get it (data structures and OO)

2007-06-04 Thread Arie Peterson
David Menendez wrote: | That's a neat idiom. I wonder how far one could usefully generalize it. | | For example, | | type Ref cx t = forall f. Functor f = (t - f t) - cx - f cx | | newtype Id a = Id { unId :: a } | instance Functor Id where fmap f = Id . f . unId | | newtype K t a

[Haskell-cafe] QuickCheck Arbitrary - infinite recursion on recursive GADTs?

2007-06-04 Thread Marc Weber
example: data A = A INt | B [A] instace Arbitrary A where arbitrary = oneof [ liftM A arbitrary , liftM B arbitrary ] But now QuickCheck will propably create a test value A ( B [ A ( B [ A - no end Is there an easy QuickCheck way to prevent

Re: [Haskell-cafe] QuickCheck Arbitrary - infinite recursion on recursive GADTs?

2007-06-04 Thread Bryan O'Sullivan
Marc Weber wrote: data A = A INt | B [A] instace Arbitrary A where arbitrary = oneof [ liftM A arbitrary , liftM B arbitrary ] But now QuickCheck will propably create a test value A ( B [ A ( B [ A - no end Is there an easy QuickCheck way

[Haskell-cafe] FOL

2007-06-04 Thread Tony Morris
I would like to know if all 16 possible functions that accept two boolean arguments have names in First-Order Logic. I know they have Haskell function names (e.g. \p - \_ - id p, \_ - \_ - const True), but I'm hoping there is a more general name that is recognised by anyone with a feel for logic,

[Haskell-cafe] FP v. OOP

2007-06-04 Thread PR Stanley
Hi BAE Systems which specialises in military technology is looking for programmers who have experience in C, C++ and Java and UML. Where soundness and completeness but especially soundness is of the essence the OOP framework is far from ideal. The FP paradigm, on the other hand, offers the

Re: [Haskell-cafe] FOL

2007-06-04 Thread Stefan O'Rear
On Tue, Jun 05, 2007 at 02:41:48PM +1000, Tony Morris wrote: I would like to know if all 16 possible functions that accept two boolean arguments have names in First-Order Logic. I know they have Haskell function names (e.g. \p - \_ - id p, \_ - \_ - const True), but I'm hoping there is a more

Re: [Haskell-cafe] What puts False before True?

2007-06-04 Thread Albert Y. C. Lai
Scott Brickner wrote: It's actually not arbitrary. [...] A ≤ B iff A ⊆ B A ⊆ B iff (x ∊ A) ⇒ (x ∊ B) Alternatively and dually but equally naturally, A ≥ B iff A ⊆ B iff (x ∊ A) ⇒ (x ∊ B) and then we would have False True. Many of you are platonists rather than formalists; you have a

Re: [Haskell-cafe] What puts False before True?

2007-06-04 Thread Derek Elkins
On Tue, 2007-06-05 at 01:16 -0400, Albert Y. C. Lai wrote: Scott Brickner wrote: It's actually not arbitrary. [...] A ≤ B iff A ⊆ B A ⊆ B iff (x ∊ A) ⇒ (x ∊ B) Alternatively and dually but equally naturally, A ≥ B iff A ⊆ B iff (x ∊ A) ⇒ (x ∊ B) and then we would have False True.

Re: [Haskell-cafe] What puts False before True?

2007-06-04 Thread PR Stanley
Hello What do the ≤ symbols represent? Thanks, Paul At 06:21 05/06/2007, you wrote: On Tue, 2007-06-05 at 01:16 -0400, Albert Y. C. Lai wrote: Scott Brickner wrote: It's actually not arbitrary. [...] A ≤ B iff A ⊆ B A ⊆ B iff (x ∊ A) ⇒ (x ∊ B) Alternatively and dually but