Re[2]: [Haskell-cafe] Newbie question about automatic memoization

2007-07-31 Thread Bulat Ziganshin
PROTECTED] Sent: Tuesday, July 31, 2007 5:09 PM To: Bryan Burgers Cc: peterv; haskell-cafe@haskell.org Subject: Re: [Haskell-cafe] Newbie question about automatic memoization Bryan Burgers wrote: On 7/30/07, peterv [EMAIL PROTECTED] wrote: Does Haskell support any form of automatic

Re: [Haskell-cafe] Newbie question about tuples

2007-07-22 Thread Andrew Coppin
Donald Bruce Stewart wrote: Yeah, there's some known low level issues in the code generator regarding heap and stack checks inside loops, and the use of registers on x86. But note this updated paper, http://www.cse.unsw.edu.au/~chak/papers/CLPKM07.html Add another core to your machine and

Re: [Haskell-cafe] Newbie question about tuples

2007-07-15 Thread Peter Verswyvelen
Donald: Yeah, there's some known low level issues in the code generator regarding heap and stack checks inside loops, and the use of registers on x86. But note this updated paper, http://www.cse.unsw.edu.au/~chak/papers/CLPKM07.html Add another core to your machine and it is no longer 4x

Re: [Haskell-cafe] Newbie question about tuples

2007-07-15 Thread Donald Bruce Stewart
bf3: Donald: Yeah, there's some known low level issues in the code generator regarding heap and stack checks inside loops, and the use of registers on x86. But note this updated paper, http://www.cse.unsw.edu.au/~chak/papers/CLPKM07.html Add another core to your machine and it is no

Re: [Haskell-cafe] Newbie question about tuples

2007-07-15 Thread Andrew Coppin
Donald Bruce Stewart wrote: bf3: Maybe this is yet another newbie stupid question, but do you mean that GHC does automatic multi-threading? (Haskell seems very suitable for that) Otherwise adding an extra core does not really help does it? No, though that would be nice! You do have to

Re: [Haskell-cafe] Newbie question about tuples

2007-07-15 Thread Donald Bruce Stewart
andrewcoppin: Donald Bruce Stewart wrote: bf3: Maybe this is yet another newbie stupid question, but do you mean that GHC does automatic multi-threading? (Haskell seems very suitable for that) Otherwise adding an extra core does not really help does it? No, though that would be nice!

RE: [Haskell-cafe] Newbie question about tuples

2007-07-15 Thread Peter Verswyvelen
Add another core to your machine and it is no longer 4x slower :) Add 15 more cores and its really no longer 4x slower : Maybe this is yet another newbie stupid question, but do you mean that GHC does automatic multi-threading? (Haskell seems very suitable for No, though that would be nice!

Re: [Haskell-cafe] Newbie question about tuples

2007-07-14 Thread Lukas Mai
Am Freitag, 13. Juli 2007 15:03 schrieb peterv: You see, in C++ I can write: [snip] So basically a wrapper around a fixed-size array of any length. Implementations of (+), (-), dot, length, normalize, etc... then work on vectors of any size, without the overhead of storing the size, and

Re[2]: [Haskell-cafe] Newbie question about tuples

2007-07-14 Thread Bulat Ziganshin
Hello Donald, Saturday, July 14, 2007, 6:01:21 AM, you wrote: don't forget that laziness by itself makes programs an orders of magnitude slower :) Or orders of magnitude faster, depending on your data structure. :) compared to naive implementation - yes, it's possible. compared to handmade

Re[4]: [Haskell-cafe] Newbie question about tuples

2007-07-14 Thread Bulat Ziganshin
] Sent: Friday, July 13, 2007 6:43 PM To: peterv Cc: 'Lukas Mai'; haskell-cafe@haskell.org Subject: Re[2]: [Haskell-cafe] Newbie question about tuples Hello peterv, Friday, July 13, 2007, 5:03:00 PM, you wrote: think the latest compilers are much better). Now when implementing something like

Re: [Haskell-cafe] Newbie question about tuples

2007-07-14 Thread Andrew Coppin
Lukas Mai wrote: You may be interested in http://okmij.org/ftp/Haskell/number-parameterized-types.html Thanks for that! It's all fascinating stuff... ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

Re: Re[4]: [Haskell-cafe] Newbie question about tuples

2007-07-14 Thread Peter Verswyvelen
Thanks Bulat, but now you scattered my hopes that GHC would magically do all these optimizations for me ;-) I must say that although the performance of Haskell is not really a concern to me, I was a bit disappointed that even with all the tricks of the state monad, unboxing, and

Re: Re[4]: [Haskell-cafe] Newbie question about tuples

2007-07-14 Thread Donald Bruce Stewart
bf3: Thanks Bulat, but now you scattered my hopes that GHC would magically do all these optimizations for me ;-) I must say that although the performance of Haskell is not really a concern to me, I was a bit disappointed that even with all the tricks of the state monad, unboxing, and

Re: [Haskell-cafe] Newbie question about tuples

2007-07-13 Thread Lukas Mai
Am Donnerstag, 12. Juli 2007 20:14 schrieb Andrew Coppin: The only thing the libraries provide, as far as I can tell, is the fact that tuples are all Functors. (In other words, you can apply some function to all the elements to get a new tuple.) I think that's about it. I doubt you can use

RE: [Haskell-cafe] Newbie question about tuples

2007-07-13 Thread peterv
://ubiety.uwaterloo.ca/~tveldhui/papers/Expression-Templates/exprtmpl.ht ml... Well at least I hope so :) -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Lukas Mai Sent: Friday, July 13, 2007 09:20 To: haskell-cafe@haskell.org Subject: Re: [Haskell-cafe] Newbie question

Re: [Haskell-cafe] Newbie question about tuples

2007-07-13 Thread Jonathan Cast
On Friday 13 July 2007, peterv wrote: I'm beginning to see that my old implementation in C++ clutters my Haskell design. You see, in C++ I can write: // A vector is an array of fixed-length N and elements of type T templatetypename T, int N struct Vector { T Element[N]; friend T

RE: [Haskell-cafe] Newbie question about tuples

2007-07-13 Thread peterv
* possible? -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Jonathan Cast Sent: Friday, July 13, 2007 16:21 To: haskell-cafe@haskell.org Subject: Re: [Haskell-cafe] Newbie question about tuples On Friday 13 July 2007, peterv wrote: I'm beginning to see

Re: [Haskell-cafe] Newbie question about tuples

2007-07-13 Thread Jules Bean
peterv wrote: with guaranteed termination, of course Just out of curiosity (not Haskell related): I always get confused when people speak about guaranteed termination; what about the halting problem? In which context can one check for guaranteed termination, as the halting problem says it's

Re[2]: [Haskell-cafe] Newbie question about tuples

2007-07-13 Thread Bulat Ziganshin
Hello peterv, Friday, July 13, 2007, 5:03:00 PM, you wrote: think the latest compilers are much better). Now when implementing something like this in Haskell, I would guess that its laziness would allow to interleave many of the math operations, reordering them to be as optimal as possible,

RE: Re[2]: [Haskell-cafe] Newbie question about tuples

2007-07-13 Thread peterv
PROTECTED] Sent: Friday, July 13, 2007 6:43 PM To: peterv Cc: 'Lukas Mai'; haskell-cafe@haskell.org Subject: Re[2]: [Haskell-cafe] Newbie question about tuples Hello peterv, Friday, July 13, 2007, 5:03:00 PM, you wrote: think the latest compilers are much better). Now when implementing

Re: [Haskell-cafe] Newbie question about tuples

2007-07-13 Thread Andrew Coppin
Lukas Mai wrote: Am Donnerstag, 12. Juli 2007 20:14 schrieb Andrew Coppin: The only thing the libraries provide, as far as I can tell, is the fact that tuples are all Functors. (In other words, you can apply some function to all the elements to get a new tuple.) I think that's about it. I

Re: [Haskell-cafe] Newbie question about tuples

2007-07-13 Thread Andrew Coppin
peterv wrote: with guaranteed termination, of course Just out of curiosity (not Haskell related): I always get confused when people speak about guaranteed termination; what about the halting problem? In which context can one check for guaranteed termination, as the halting problem says

Re: [Haskell-cafe] Newbie question about tuples

2007-07-13 Thread Jules Bean
Andrew Coppin wrote: Lukas Mai wrote: Am Donnerstag, 12. Juli 2007 20:14 schrieb Andrew Coppin: The only thing the libraries provide, as far as I can tell, is the fact that tuples are all Functors. (In other words, you can apply some function to all the elements to get a new tuple.) I think

Re: [Haskell-cafe] Newbie question about tuples

2007-07-13 Thread Donald Bruce Stewart
bulat.ziganshin: Hello peterv, Friday, July 13, 2007, 5:03:00 PM, you wrote: think the latest compilers are much better). Now when implementing something like this in Haskell, I would guess that its laziness would allow to interleave many of the math operations, reordering them to be

[Haskell-cafe] Newbie question about tuples

2007-07-12 Thread peterv
Hi, I have a couple of questions about tuples. Q1) Is it possible to treat a tuple of N elements in a generic way? So instead of writing functions like lift1 e1, lift2 (e1,e2), lift3 (e1,e2,e3) just one function liftN that works on tuples of any length? Q2) (Maybe related to Q1) Can I convert

Re: [Haskell-cafe] Newbie question about tuples

2007-07-12 Thread Benja Fallenstein
Hi Peter, 2007/7/12, peterv [EMAIL PROTECTED]: Q1) Is it possible to treat a tuple of N elements in a generic way? So instead of writing functions like lift1 e1, lift2 (e1,e2), lift3 (e1,e2,e3) just one function liftN that works on tuples of any length? Q2) (Maybe related to Q1) Can I convert

Re: [Haskell-cafe] Newbie question about tuples

2007-07-12 Thread Andrew Coppin
peterv wrote: Hi, I have a couple of questions about tuples. Q1) Is it possible to treat a tuple of N elements in a generic way? So instead of writing functions like lift1 e1, lift2 (e1,e2), lift3 (e1,e2,e3) just one function liftN that works on tuples of any length? The only thing the

Re: [Haskell-cafe] Newbie question about tuples

2007-07-12 Thread Henning Thielemann
On Thu, 12 Jul 2007, Andrew Coppin wrote: peterv wrote: Q3) Suppose I want to declare an instance of Num on all tuple types having (Num instances) as elements; is this possible? I tried instance Num a = Num (a,a) where . but this fails I also tried

Re: [Haskell-cafe] Newbie question about tuples

2007-07-12 Thread Jonathan Cast
peterv wrote: Hi, I have a couple of questions about tuples. Q1) Is it possible to treat a tuple of N elements in a generic way? So instead of writing functions like lift1 e1, lift2 (e1,e2), lift3 (e1,e2,e3) just one function liftN that works on tuples of any length? If you have instances

[Haskell-cafe] Newbie question: alternative for toInt/fromInt

2007-06-28 Thread peterv
I'm trying to get the SOE graphics library to compile for Win32 using the latest libraries. I fixed a couple of imports, but in the file GraphicsTypes.hs, the functions toInt/fromInt are used, which are now obsolete: type Dimension = Int toDimension:: Win32.INT - Dimension

Re: [Haskell-cafe] Newbie question: alternative for toInt/fromInt

2007-06-28 Thread Stefan O'Rear
On Thu, Jun 28, 2007 at 09:16:37PM +0200, peterv wrote: I'm trying to get the SOE graphics library to compile for Win32 using the latest libraries. I fixed a couple of imports, but in the file GraphicsTypes.hs, the functions toInt/fromInt are used, which are now obsolete: type Dimension =

Re: [Haskell-cafe] Newbie question: alternative for toInt/fromInt

2007-06-28 Thread Thomas Schilling
toInt = id fromInt = id ? On 28 jun 2007, at 21.16, peterv wrote: I’m trying to get the SOE graphics library to compile for Win32 using the latest libraries. I fixed a couple of imports, but in the file GraphicsTypes.hs, the functions toInt/fromInt are used, which are now obsolete:

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

2007-06-05 Thread Ilya Tsindlekht
On Mon, Jun 04, 2007 at 05:42:35PM +0300, Juozas Gaigalas 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

[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

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] 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] newbie question on ordering

2007-04-23 Thread Joe Thornber
On 22/04/07, Nikolay Metchev [EMAIL PROTECTED] wrote: Hello guys, I have decided to try and get back into Haskell recently. I have used it in the past but have forgotten large chunks. I am trying to express the logic of a particular card game. For this purpose I need to be able to order cards in

[Haskell-cafe] newbie question on ordering

2007-04-22 Thread Nikolay Metchev
Hello guys, I have decided to try and get back into Haskell recently. I have used it in the past but have forgotten large chunks. I am trying to express the logic of a particular card game. For this purpose I need to be able to order cards in various orders. At first I thought that the Ord class

Re: [Haskell-cafe] newbie question on ordering

2007-04-22 Thread Albert Y. C. Lai
Nikolay Metchev wrote: data Face = Ace | Two | Three | Four | Five | Six | Seven | Eight | Nine | Ten | Jack | Queen | King deriving (Enum, Show, Eq) listComparator :: (Eq a) = [a] - a - a - Ordering listComparator xs a b = compare x y where x =

[Haskell-cafe] Newbie question: ghc search path for .c files

2007-03-16 Thread Seth J. Fogarty
Hi, I am having difficulty compiling a program that uses a foreign library. The readme says to first compile a C file: : ghc mipFFI.c -c mipFFI.c:1:0: lpkit.h: No such file or directory Alright, that's not uncommon. gcc confirms : gcc mipFFI.c mipFFI.c:1: lpkit.h: No such file or directory

Re: [Haskell-cafe] Newbie question: ghc search path for .c files

2007-03-16 Thread Ian Lynagh
Hi Seth, On Fri, Mar 16, 2007 at 01:53:49PM -0500, Seth J. Fogarty wrote: : ghc -i/home/sfogarty/lib/lp_solve_5.5 mipFFI.c mipFFI.c:1:0: lpkit.h: No such file or directory ghc -I/home/sfogarty/lib/lp_solve_5.5 mipFFI.c should work. If not, add -v to the commandline to see what it is

[Haskell-cafe] newbie question about denotational semantics

2007-02-20 Thread Alexander Vodomerov
Hi all! I'm just started learning denotational semantics and have a simple question. Suppose, we have simple language L (e.g. some form of lambda-calculus) and have a semantic function: E : Term_L - Value. Now, suppose, we extended our language with some additional side-effects (e.g. state

Re: [Haskell-cafe] newbie question about denotational semantics

2007-02-20 Thread Nicolas Frisby
I'm still getting my head around this myself, but I know a few references that might help (maybe not directly, but they're in the ballpark). 1 I believe the phrase natural lifting or naturality of liftings is what you're after when you attempt to compare a monad and a bigger monad that includes

Re: [Haskell-cafe] newbie question about denotational semantics

2007-02-20 Thread Nicolas Frisby
[my mail program hiccuped and chopped my message, sorry] 2 Another example that helped me when getting a feel for reasoning about monadic code (which is the basis of what we're doing here) was William Harrison's Proof Abstraction for Imperative Languages. It uses monads and some of the notions

[Haskell-cafe] Newbie question

2006-12-29 Thread Pieter Laeremans
Hi, I'm reading the Haskell school of expression by Paul Hudok. Great book. However I would like some feedback about a solution to an exercise The problem is quite simple : define f1 and f2 (using higher order functions ) such that f1 (f2 (*) [1..4]) 5 = [5,10,15,20] I have come up with the

Re: [Haskell-cafe] Newbie question

2006-12-29 Thread Bernie Pope
On 30/12/2006, at 1:33 PM, Pieter Laeremans wrote: Hi, I'm reading the Haskell school of expression by Paul Hudok. Great book. Hudak. And I concur, a great book. However I would like some feedback about a solution to an exercise The problem is quite simple : define f1 and f2 (using

Re: [Haskell-cafe] Newbie question on iterating over IO list

2006-06-20 Thread Jared Updike
o To output anything, I need to do 'do'. If you only have one action, you can omit do, e.g. main = do { putStrLn Hello, World! } is identical (after de-sguaring) to main = putStrLn Hello, World! Essentially, you are correct; to output anything (i.e. to perform I/O by side effect) your

Re[2]: [Haskell-cafe] Newbie question on iterating over IO list

2006-06-20 Thread Bulat Ziganshin
Hello Taro, Tuesday, June 20, 2006, 9:32:51 AM, you wrote: o To output anything, I need to do 'do'. no, you should perform something having IO ... return type. do is just a syntax way to join several IO ... actions into one action having this type. i plan to write i/o and monads for beginners

Re: [Haskell-cafe] Newbie question on iterating over IO list

2006-06-20 Thread minh thu
2006/6/20, Taro Ikai [EMAIL PROTECTED]: Sebastian, Thanks for your help. I learned two things: o show is not an action, but a function. Using it in the interactive mode of GHCI was making me confused. hi, in ghci, if I want to see the result of an IO action, I do this ghci x - myIOAction

[Haskell-cafe] Newbie question on iterating over IO list

2006-06-19 Thread Taro Ikai
Here's a code fragment I have from working with Hal Daume's Yet Another Haskell Tutorial. I cannot figure out how to iterate over the result from askForNumbers that returns IO [Integer], and print them. The - operator seems to take IO off of the results from actions like getContents, which

Re: [Haskell-cafe] Newbie question on iterating over IO list

2006-06-19 Thread Sebastian Sylvan
On 6/20/06, Taro Ikai [EMAIL PROTECTED] wrote: Here's a code fragment I have from working with Hal Daume's Yet Another Haskell Tutorial. I cannot figure out how to iterate over the result from askForNumbers that returns IO [Integer], and print them. The - operator seems to take IO off of the

Re: [Haskell-cafe] Newbie question on iterating over IO list

2006-06-19 Thread Taro Ikai
Sebastian, Thanks for your help. I learned two things: o show is not an action, but a function. Using it in the interactive mode of GHCI was making me confused. o To output anything, I need to do 'do'. -Taro Sebastian Sylvan wrote: On 6/20/06, Taro Ikai [EMAIL PROTECTED] wrote: Here's a

Re: [Haskell-cafe] Newbie question: inferred type

2006-03-31 Thread Imam Tashdid ul Alam
most probably yes. I had the exact same question for: module Factors where import Prelude divides x y = (mod x y == 0) factors x = filter (divides x) [1..x] nonTrivialFactors x = filter (\y - y /= 1 y /= x) [1..x] isEmpty [] = True isEmpty _ = False -- isPrime = isEmpty .

[Haskell-cafe] Newbie question: inferred type

2006-03-29 Thread David Laffin
Hi, Newbie question. Given the inferred type for square, the inferred types for quad1, quad2 and quad3 are what I would expect. Is there a straightforward explanation (i.e. one that a newbie would understand) as to why the inferred type for quad4 is less general? Regards, dl -- GHC

Re: [Haskell-cafe] Newbie question: inferred type

2006-03-29 Thread Neil Mitchell
I think this is the monomorphism restriction, you can see more details on the web page: http://www.haskell.org/hawiki/MonomorphismRestriction On 3/30/06, David Laffin [EMAIL PROTECTED] wrote: Hi, Newbie question. Given the inferred type for square, the inferred types for quad1, quad2 and

[Haskell-cafe] (Newbie Question) How to get the value of an IO String Monad?

2006-02-17 Thread Peter
Hello, For the purpose of familiarizing myself with Haskell, and also because I love Haskell :), I am trying to re-make a script that I made in Python that sends a request to a server and extracts the list of email addresses from a Mailman web-page by using an XML Parser on the page's HTML that

Re: [Haskell-cafe] (Newbie Question) How to get the value of an IO String Monad?

2006-02-17 Thread Marc Weber
You can access IO values only from within do blocks (see any tutorial, previous posts or google). It looks like this then: do= myvalue - functionwhichreturnsIOValue dosomethingwith myvalue Due to monads you don't have to leave the IO monad this way. Oh. Have to go now. do is translated into

Re: [Haskell-cafe] (Newbie Question) How to get the value of an IO String Monad?

2006-02-17 Thread Ketil Malde
Peter [EMAIL PROTECTED] writes: So, How am I supposed to get the value of an IO Monad, such as IO String, without returning an IO Monad? Short answer: you don't. IO is a one way street. Build your application top down in the IO monad (starting with 'main'), and bottom up with pure code,

Re: [Haskell-cafe] (Newbie Question) How to get the value of an IO String Monad?

2006-02-17 Thread Lemmih
On 2/17/06, Peter [EMAIL PROTECTED] wrote: Hello, For the purpose of familiarizing myself with Haskell, and also because I love Haskell :), I am trying to re-make a script that I made in Python that sends a request to a server and extracts the list of email addresses from a Mailman web-page

Re: [Haskell-cafe] (Newbie Question) How to get the value of an IO String Monad?

2006-02-17 Thread Daniel Fischer
Hi, Am Freitag, 17. Februar 2006 14:42 schrieb Peter: Hello, For the purpose of familiarizing myself with Haskell, and also because I love Haskell :), very good! I am trying to re-make a script that I made in Python that sends a request to a server and extracts the list of email addresses

Re: [Haskell-cafe] (Newbie Question) How to get the value of an IO String Monad?

2006-02-17 Thread Udo Stenzel
Peter wrote: So, How am I supposed to get the value of an IO Monad, such as IO String, without returning an IO Monad? You read correctly, this is impossible. You already got some valid answers, and here's another variant that preserves most of the nice guarded expressions: recv_headers' ::

Re: [Haskell-cafe] (Newbie Question) How to get the value of an IO String Monad?

2006-02-17 Thread Cale Gibbard
Hi, Apart from the other posts, you might also want to read http://www.haskell.org/hawiki/IntroductionToIO which is a quick intro to the way IO is handled in Haskell and http://www.haskell.org/hawiki/UsingIo which covers similar ground, but which also goes into a number of other common questions.

Re: [Haskell-cafe] Newbie question on Haskell type

2005-10-16 Thread Huong Nguyen
Thanks all of your for your time and your interesting examples. Now I can see that my problem is parsing a String. I am new in Haskell, so, I start to study parsing and how to create a parser from beginning. I start with an example from the book as follows: %The parser item fails if the input is

Re: [Haskell-cafe] Newbie question on Haskell type

2005-10-16 Thread Albert Lai
Huong Nguyen [EMAIL PROTECTED] writes: newtype Parser a = Parser(String - [(a, String)]) [...] parse :: Parser a - String - [(a, String)] parse p cs = p cs \end{code} Try this instead: parse (Parser p) cs = p cs (You forgot to deconstruct! :) )

Re: [Haskell-cafe] Newbie question on Haskell type

2005-10-14 Thread Cale Gibbard
Right, forgot about seq there, but the point still holds that there are a very limited number of functions of that type, and in particular, the functions can't decide what to do based on the type parameter 'a'. - Cale On 14 Oct 2005 05:49:27 -, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:

Re: [Haskell-cafe] Newbie question on Haskell type

2005-10-14 Thread John Meacham
On Fri, Oct 14, 2005 at 03:17:12AM -0400, Cale Gibbard wrote: Right, forgot about seq there, but the point still holds that there are a very limited number of functions of that type, and in particular, the functions can't decide what to do based on the type parameter 'a'. actually, without

Re: [Haskell-cafe] Newbie question on Haskell type

2005-10-14 Thread Ben Rudiak-Gould
Cale Gibbard wrote: As an example of this sort of thing, I know that there are only 4 values of type a - Bool (without the class context). They are the constant functions (\x - True), (\x - False), and two kinds of failure (\x - _|_), and _|_, where _|_ is pronounced bottom and represents

Re: [Haskell-cafe] Newbie question on Haskell type

2005-10-14 Thread Sebastian Sylvan
On 10/13/05, Huong Nguyen [EMAIL PROTECTED] wrote: Hi all, I want to write a small functionto test whether an input is a String or not. For example, isString::(Show a) =a -Bool This function will return True if the input is a string and return False if not Any of you have idea about

Re: [Haskell-cafe] Newbie question on Haskell type

2005-10-14 Thread robert dockins
So this is essentially a parsing problem. You want a user to be able input a string and have it interpreted as an appropriate data value. I think you may want to look at the Parsec library (http://www.cs.uu.nl/~daan/parsec.html). I don't think the direction you are heading will get the

Re: [Haskell-cafe] Newbie question on Haskell type

2005-10-14 Thread Ralf Hinze
Hi Huong, attached you find a small program for parsing values of various (data) types. It uses a generalized algebraic data type for representing types and a universal data type for representing values. The parser itself is rather simple-minded: it builds on Haskell's ReadS type. I don't know

[Haskell-cafe] Newbie question on Haskell type

2005-10-13 Thread Huong Nguyen
Hi all, I want to write a small functionto test whether an input is a String or not. For example, isString::(Show a) =a -Bool This function will return True if the input is a string and return False if not Any of you have idea about that? Thanks in advance

Re: [Haskell-cafe] Newbie question on Haskell type

2005-10-13 Thread Neil Mitchell
isString::(Show a) =a -Bool This function will return True if the input is a string and return False if not This is not particularly nicely - you certainly can't write it as simple as the 'isString' function, and it will probably require type classes etc, quite possibly with haskell extensions.

Re: [Haskell-cafe] Newbie question on Haskell type

2005-10-13 Thread robert dockins
In GHC you can do this: import Data.Typeable isString :: (Typeable a) = a - Bool isString x = typeOf x == typeOf (undefined::String) Why do you want this? It's not the kind of operation one does very often in Haskell. Huong Nguyen wrote: Hi all, I want to write a small functionto

Re: [Haskell-cafe] Newbie question on Haskell type

2005-10-13 Thread voigt . 16734551
--- Cale Gibbard [EMAIL PROTECTED] wrote: As an example of this sort of thing, I know that there are only 4 values of type a - Bool (without the class context). They are the constant functions (\x - True), (\x - False), and two kinds of failure (\x - _|_), and _|_, where _|_ is pronounced

[Haskell-cafe] Newbie question: how to run HaXML in Unix

2005-09-22 Thread Huong Nguyen
Hello everybody, This seems so simple question, but I did not find the solution. HaXML is installed. Do you know how I can run HaXML in Linux/Unix (which command I should write). Thank you. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

Re: [Haskell-cafe] Newbie question: how to run HaXML in Unix

2005-09-22 Thread Malcolm Wallace
Huong Nguyen [EMAIL PROTECTED] writes: HaXML is installed. Do you know how I can run HaXML in Linux/Unix (which command I should write). Thank you. That depends what you want to do with it. HaXml is a library of modules for processing XML, so one answer to your question is just write some

[Haskell-cafe] Newbie question

2005-08-12 Thread André Vargas Abs da Cruz
Hi everyone, I think this is a totally newbie question as i am a complete novice to Haskell. I am trying to write down a few programs using GHC in order to get used with the language. I am having some problems with a piece of code (that is supposed to return a list of lines from a text

Re: [Haskell-cafe] Newbie question

2005-08-12 Thread Lemmih
On 8/12/05, David Roundy [EMAIL PROTECTED] wrote: On Fri, Aug 12, 2005 at 09:17:32AM -0300, Andr Vargas Abs da Cruz wrote: readDataFromFile filename = do bracket (openFile filename ReadMode) hClose (\h - do contents - hGetContents h return (lines

Re: [Haskell-cafe] Newbie question

2005-08-12 Thread David Roundy
On Fri, Aug 12, 2005 at 02:54:03PM +0200, Lemmih wrote: On 8/12/05, David Roundy [EMAIL PROTECTED] wrote: On Fri, Aug 12, 2005 at 09:17:32AM -0300, Andr Vargas Abs da Cruz wrote: readDataFromFile filename = do bracket (openFile filename ReadMode) hClose (\h - do contents

Re: [Haskell-cafe] Newbie question

2005-08-12 Thread Glynn Clements
André Vargas Abs da Cruz wrote: I think this is a totally newbie question as i am a complete novice to Haskell. I am trying to write down a few programs using GHC in order to get used with the language. I am having some problems with a piece of code (that is supposed to return a list

Re: [Haskell-cafe] Newbie question

2005-08-12 Thread André Vargas Abs da Cruz
Thank you all for your answers. I'll try to be more careful with lazy evaluations while doing IO operations from now on. Best regards André On Fri, Aug 12, 2005 at 02:54:03PM +0200, Lemmih wrote: On 8/12/05, David Roundy [EMAIL PROTECTED] wrote: On Fri, Aug 12, 2005 at 09:17:32AM

Re: [Haskell-cafe] Newbie question

2005-08-12 Thread Cale Gibbard
This question comes up often, and there are lots of ways to answer it. Not too long ago, I posted a simplistic (but not terribly practical) solution, writing a strict version of readFile in terms of hGetChar, to which Simon Marlow replied with an actually pratical implementation which allocates

[Haskell-cafe] Newbie question about Read strings in a line of File

2005-07-26 Thread Huong Nguyen
Hello everybody, Now I am writing a module to handles messages of a system. The messages are stored in a file. The content of each line of the file likes this: 1001 001 Error message 1 1001 002 Error message 2 1002

Re: [Haskell-cafe] Newbie question about Read strings in a line of File

2005-07-26 Thread Cale Gibbard
Here's how I wrote it: - beginning of file import IO -- turn a line of the text file into a pair consisting of -- the message triple and the message string -- slight bug: will contract multiple spaces in the message string -- This could be rewritten to avoid this problem, but couldn't make

Re: [Haskell-cafe] Newbie Question about Error Handling

2005-07-25 Thread Gerd M
We're being clever and returning from IO not a Char, but a MyMonad Char (mimp). Then, we run that, which either produces the answer we wanted, or throws an error in MyMonad. Thanks. That did the trick! :-) Regards However, it's still rather cumbersome, so here's a function similar to

[Haskell-cafe] Newbie Question about Error Handling

2005-07-24 Thread Gerd M
Hello! I'm confused by the error handling in Haskell. I've written a program that uses a combined monad of type: type MyMonad a = ErrorT MyErrorType (StateT MyStateType IO) a (MyErrorType is an instance of Error) Therefore, to handle IO Errors inside of MyMonad I need to write: foo :: MyMonad

Re: [Haskell-cafe] Newbie Question about Error Handling

2005-07-24 Thread Andrew Pimlott
On Sun, Jul 24, 2005 at 08:00:58PM +, Gerd M wrote: Hello! I'm confused by the error handling in Haskell. I've written a program that uses a combined monad of type: type MyMonad a = ErrorT MyErrorType (StateT MyStateType IO) a (MyErrorType is an instance of Error) Therefore, to handle

[Haskell-cafe] Newbie question -- fromInt

2005-04-28 Thread Tim Rowe
I'm working through The craft of functional programming , and I've come to excercise 3.14: Give a function to return the average of three integers. My attempt at an answer is: averageThree :: Int - Int - Int - Float averageThree a b c = fromInt(a + b + c) / 3 but when I try to load this file I

Re: [Haskell-cafe] Newbie question -- fromInt

2005-04-28 Thread Cale Gibbard
The function fromInt is no longer around. Use fromIntegral instead, which works with Int and Integer. On 4/28/05, Tim Rowe [EMAIL PROTECTED] wrote: I'm working through The craft of functional programming , and I've come to excercise 3.14: Give a function to return the average of three

Re: [Haskell-cafe] Newbie Question on type constructors

2004-11-04 Thread Paul Hudak
Sorry, I had to drop out of this thread for a few days... Ben Rudiak-Gould wrote: Paul Hudak wrote: Note that instead of: data Shape = Circle Float | Square Float the Haskell designers might have used the following syntax: data Shape where Circle :: Float - Shape

Re: [Haskell-cafe] Newbie Question on type constructors

2004-11-02 Thread Ketil Malde
Ben Rudiak-Gould [EMAIL PROTECTED] writes: In particular, your notation with type signatures makes it totally unclear that Circle and Square have disjoint ranges; in fact it looks like they have the same range. : The syntax that would have made the most sense to me would have been

Re: [Haskell-cafe] Newbie Question on type constructors

2004-11-02 Thread Keith Wansbrough
Put the data declaration in a module, export the type, but not the constructor you want to hide: module Shape (Shape(Square), circle) where Since we were talking about 'what can one do with a constructor as compared with a function', it should be mentioned that this also has a

Re: [Haskell-cafe] Newbie Question on type constructors

2004-11-01 Thread Ben Rudiak-Gould
Brian Beckman wrote: data Shape = Circle Float | Square Float I read this something along the lines of 'Shape' is a type constructor, for use in other type-defining expressions, and 'Circle' and 'Sqare' are its two data constructors, which should be used like functions of type 'Float -

Re: [Haskell-cafe] Newbie Question on type constructors

2004-11-01 Thread Keith Wansbrough
Oh, I disagree with this point of view. Circle is certainly a value, i.e. a full-fledged function, as Brian Beckman correctly surmised. The Ben Rudiak-Gould wrote: Brian Beckman wrote: data Shape = Circle Float | Square Float I read this something along the

Re: [Haskell-cafe] Newbie Question on type constructors

2004-11-01 Thread Ben Rudiak-Gould
Paul Hudak wrote: Oh, I disagree with this point of view. Circle is certainly a value, i.e. a full-fledged function, as Brian Beckman correctly surmised. Interesting. I don't claim that my viewpoint is the One True Path, but I don't think it's wrong, either. I know you're interested in the

Re: [Haskell-cafe] Newbie Question on type constructors

2004-11-01 Thread Ben Rudiak-Gould
Keith Wansbrough wrote: Indeed, they are functions. Another way of thinking about it is as an initial algebra (technical term). What this means is this: Shape is a set of values that contains - the result of Circle x for all values x :: Float - the result of Square x for all

Re: [Haskell-cafe] Newbie Question on type constructors

2004-11-01 Thread Henning Thielemann
On Mon, 1 Nov 2004, Ben Rudiak-Gould wrote: Paul Hudak wrote: Oh, I disagree with this point of view. Circle is certainly a value, i.e. a full-fledged function, as Brian Beckman correctly surmised. Interesting. I don't claim that my viewpoint is the One True Path, but I don't think

<    1   2   3   >