Re: [Haskell-cafe] Re: nested maybes

2007-02-05 Thread Bulat Ziganshin
Hello Martin, Monday, February 5, 2007, 2:47:33 AM, you wrote: main = do minput - getInput case minput of Nothing - printError Just input - do mresult - processInput input case mresult of Nothing - printError Just result - printResult

Re: [Haskell-cafe] Re: nested maybes

2007-02-05 Thread Yitzchak Gale
J. Garrett Morris wrote: This is where my favorite part of the mtl steps in: monad transformers. I agree, the Error monad is very helpful here. First, we'll create a transformed version of the IO monad, Why go to the trouble of creating a new monad? The existing ones are fine. (While

Re: Re[2]: [Haskell-cafe] nested maybes

2007-02-05 Thread Martin DeMello
On 2/5/07, Bulat Ziganshin [EMAIL PROTECTED] wrote: Hello J., Sunday, February 4, 2007, 11:46:57 PM, you wrote: exists s wmap = isJust $ find (==s) . snd = Map.lookup (sort s) wmap exists s wmap = Map.lookup (sort s) wmap == snd == find (==s)

[Haskell-cafe] OT: any haskell-friendly / functional programming friendly comp sci programs? (for a 30s guy who did his undergrad in liberal arts)

2007-02-05 Thread Thomas Hartman
haskellers, I'm contemplating returning to school after a decade as a worker bee, and almost that long as a worker bee doing computer consulting / miscelaneous tech stuff. Ideally I'd like to get a masters, but I don't know if that's feasible this late in the game. If it's not, I might settle

Re: [Haskell-cafe] OT: any haskell-friendly / functional programming friendly comp sci programs? (for a 30s guy who did his undergrad in liberal arts)

2007-02-05 Thread minh thu
2007/2/5, Thomas Hartman [EMAIL PROTECTED]: haskellers, I'm contemplating returning to school after a decade as a worker bee, and almost that long as a worker bee doing computer consulting / miscelaneous tech stuff. Ideally I'd like to get a masters, but I don't know if that's feasible this

Re: [Haskell-cafe] OT: any haskell-friendly / functional programming friendly comp sci programs? (for a 30s guy who did his undergrad in liberal arts)

2007-02-05 Thread Greg Fitzgerald
Thomas, Here's a good place to start, although I'm not sure how up to date it is: http://haskell.org/haskellwiki/Haskell_in_education I too am interested in an FP-related, higher education in California. Could you please send another post with whatever information you find? Thanks, Greg On

Re: [Haskell-cafe] Generalizing three programs

2007-02-05 Thread Yitzchak Gale
Andrew Wagner wrote: I've got several problems which seem to have a very similar structure. I want to find a way to abstract them to solve other problems which can be thought about in the same way. Here they are: http://hpaste.org/307 http://hpaste.org/308 http://hpaste.org/309 Note that these

Re: [Haskell-cafe] Re: nested maybes

2007-02-05 Thread J. Garrett Morris
On 2/5/07, Yitzchak Gale [EMAIL PROTECTED] wrote: J. Garrett Morris wrote: First, we'll create a transformed version of the IO monad, Why go to the trouble of creating a new monad? The existing ones are fine. Mainly to keep the type error messages simpler. A project I was working on started

Re: [Haskell-cafe] Re: nested maybes

2007-02-05 Thread Yitzchak Gale
I wrote: Why go to the trouble of creating a new monad? The existing ones are fine. J. Garrett Morris wrote: Mainly to keep the type error messages simpler. There are two ways to get around that problem: 1. Make your functions polymorphic, using MonadState, MonadError, etc. Each function

Re: [Haskell-cafe] OT: any haskell-friendly / functional programming friendly comp sci programs? (for a 30s guy who did his undergrad in liberal arts)

2007-02-05 Thread Malcolm Wallace
Thomas Hartman [EMAIL PROTECTED] wrote: Whether master's, bachelor's, or other, I am specifically interested in programs that are functional friendly. You might find that Utrecht has something of interest, e.g. the Masters in Software Technology.

Re: [Haskell-cafe] mixing wxhaskell state and file io

2007-02-05 Thread Martin DeMello
On 2/5/07, Martin DeMello [EMAIL PROTECTED] wrote: On 2/5/07, Matthew Brecknell [EMAIL PROTECTED] wrote: This is probably what you wanted (untested): w - readWords words words - varCreate w That didn't work, because (as someone on #haskell explained to me) readWords has type IO and the wx

Re: [Haskell-cafe] Re: nested maybes

2007-02-05 Thread J. Garrett Morris
On 2/5/07, Yitzchak Gale [EMAIL PROTECTED] wrote: J. Garrett Morris wrote: Mainly to keep the type error messages simpler. There are two ways to get around that problem: 1. Make your functions polymorphic, using MonadState, MonadError, etc. Each function mentions only the capabilities that it

Re: [Haskell-cafe] nested maybes

2007-02-05 Thread Bryan Donlan
Martin DeMello wrote: On 2/5/07, Bulat Ziganshin [EMAIL PROTECTED] wrote: Hello J., Sunday, February 4, 2007, 11:46:57 PM, you wrote: exists s wmap = isJust $ find (==s) . snd = Map.lookup (sort s) wmap exists s wmap = Map.lookup (sort s) wmap == snd ==

[Haskell-cafe] Re: Generalizing three programs

2007-02-05 Thread apfelmus
Andrew Wagner wrote: Hi everyone, I've got an interesting problem here I'm trying to solve. Actually, I've got several problems which seem to have a very similar structure. I want to find a way to abstract them to solve other problems which can be thought about in the same way. Here they are:

[Haskell-cafe] how to calculate the sum of list of lists?

2007-02-05 Thread Miranda Kajtazi
Help, How to calculate the sum of list of lists in Haskell? Please help me, Miranda ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] how to calculate the sum of list of lists?

2007-02-05 Thread Neil Mitchell
Hi Miranda, How to calculate the sum of list of lists in Haskell? What do you mean by this? What is the value of a list? If you mean sum the numbers such that [[1,2],[3,4]] = 1+2+3+4 then you are able to ask two alternative questions - how do i convert a list of lists to a list, and how do i

Re: [Haskell-cafe] how to calculate the sum of list of lists?

2007-02-05 Thread Eric Olander
If I understand you correctly, this should do it: sums :: Num a = [[a]] - a sums l = sum [sum p | p - l] -Eric On 2/5/07, Miranda Kajtazi [EMAIL PROTECTED] wrote: Help, How to calculate the sum of list of lists in Haskell? Please help me, Miranda

Re: [Haskell-cafe] how to calculate the sum of list of lists?

2007-02-05 Thread Maxime Henrion
Miranda Kajtazi wrote: Help, How to calculate the sum of list of lists in Haskell? Do you mean something of the form Num a = [[a]] - a ? If so, this should do it: Prelude let foo = sum . concat Prelude foo [[1,2,3],[4,5]] 15 Cheers, Maxime ___

Re: [Haskell-cafe] OT: any haskell-friendly / functional programming friendly comp sci programs? (for a 30s guy who did his undergrad in liberal arts)

2007-02-05 Thread Björn Bringert
Thomas Hartman wrote: haskellers, I'm contemplating returning to school after a decade as a worker bee, and almost that long as a worker bee doing computer consulting / miscelaneous tech stuff. Ideally I'd like to get a masters, but I don't know if that's feasible this late in the game. If it's

Re: [Haskell-cafe] how to calculate the sum of list of lists?

2007-02-05 Thread Mark T.B. Carroll
Miranda Kajtazi [EMAIL PROTECTED] writes: Help, How to calculate the sum of list of lists in Haskell? So the answer for [[1,2],[3,4]] would be 10? (Is this homework? If so, we're still happy to give hints.) -- Mark ___ Haskell-Cafe mailing list

[Haskell-cafe] How to remove all numbers from a list that are divisible by an integer

2007-02-05 Thread Miranda Kajtazi
Hi, Thanx to all for the previous hints how to solve and write the function to calculate the sum of a list of lists. Now I need to know how to remove all numbers that are divisable by an integer. Lets say I have a list [2,4,5,6,8] and when I divide them with number 2, my list should look like

Re: [Haskell-cafe] How to remove all numbers from a list that are divisible by an integer

2007-02-05 Thread Neil Mitchell
Hi Miranda, Now I need to know how to remove all numbers that are divisable by an integer. Is this a homework problem? Is there some bigger goal you are trying to achieve? I tried to use some zipWith...filter and other predefined functions..but I can't really find the right solution :(

[Haskell-cafe] How to use infinite lists to define the list of all negative integers

2007-02-05 Thread Bahtijar Vogel
Hi, How am I supposed to use infinite lists to define the list of all negative integers? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

[Haskell-cafe] Re: How to use infinite lists to define the list of all negative integers

2007-02-05 Thread Max Vasin
Bahtijar == Bahtijar Vogel [EMAIL PROTECTED] writes: Bahtijar Hi, How am I supposed to use infinite lists to define Bahtijar the list of all negative integers? negs = [-1,-2..] -- WBR, Max Vasin. ___ Haskell-Cafe mailing list

Re: [Haskell-cafe] How to use infinite lists to define the list of all negative integers

2007-02-05 Thread Andrew Wagner
Hi Bahtijar! I'm not going to answer your question directly, but let me give you some background that will hopefully help you discover the pretty solution yourself. Consider this definition: ones = 1 : ones -- This list is essentially [1,1,1,...] And this expression: take 5 ones Now,

[Haskell-cafe] How to remove all numbers from a list that are divisible by an integer

2007-02-05 Thread Miranda Kajtazi
Hi all, I'm trying to create a function which filters out all number from a list that are divisible by an integer. Ex. the list [2,3,4,5,6] div 2...should give me the list like: [3,5], other numbers should be removed divisible by 2. filter :: (a - Bool) - [a] - [a] filter p [] = [] filter p

[Haskell-cafe] Space leaks in large mutable data structures

2007-02-05 Thread C Rodrigues
I'd like to hear what tips and techniques you guys have for avoiding space leaks. I understand the basic techniques to force evaluation of closures. What I'd like to know is how you avoid space leaks in large, long-lived, mutable data structures. These kind of data are particularly sensitive

Re: [Haskell-cafe] How to remove all numbers from a list that are divisible by an integer

2007-02-05 Thread Neil Mitchell
Hi Miranda, filter :: (a - Bool) - [a] - [a] filter p [] = [] filter p (x:xs) = if p 'mod' x then x : filter p xs else filter p xs I tried this, but it doesn't work You are mixing a few things together. First point, mod should be `mod` and not

Re: [Haskell-cafe] How is laziness defined?

2007-02-05 Thread David House
On 05/02/07, TJ [EMAIL PROTECTED] wrote: I went through the entry on laziness on the wikipedia wikibook. Very nice. The wikibook sure has grown a lot since I last visited. http://en.wikibooks.org/wiki/Haskell/Laziness Great! I was about to suggest this! This is one of our

Re: [Haskell-cafe] How to use infinite lists to define the list of all negative integers

2007-02-05 Thread David House
On 05/02/07, Bahtijar Vogel [EMAIL PROTECTED] wrote: Hi, How am I supposed to use infinite lists to define the list of all negative integers? Don't forget the iterate function: http://haskell.org/ghc/docs/latest/html/libraries/base/Data-List.html#v%3Aiterate Also, I may be off the mark here,

Re: [Haskell-cafe] OT: any haskell-friendly / functional programming friendly comp sci programs? (for a 30s guy who did his undergrad in liberal arts)

2007-02-05 Thread Michael Vanier
FYI we teach and do a fair amount of functional programming here at Caltech. We have courses using scheme, ocaml, and haskell with more on the way. Mike Greg Fitzgerald wrote: Thomas, Here's a good place to start, although I'm not sure how up to date it is:

Re: [Haskell-cafe] Timezone Database Library

2007-02-05 Thread Ian Lynagh
On Fri, Feb 02, 2007 at 01:54:13PM +, Martin Percossi wrote: Hello, is there a haskell library that provides facilities to read and use the tzfile format [1], or equivalent in Windows? Not as far as I am aware. Thanks Ian ___ Haskell-Cafe

Re: [Haskell-cafe] OT: any haskell-friendly / functional programming friendly comp sci programs? (for a 30s guy who did his undergrad in liberal arts)

2007-02-05 Thread Kirsten Chevalier
On 2/5/07, Paul Johnson [EMAIL PROTECTED] wrote: If you are already a hacker then the right kinds of people to start a company with may not be the ones you find in a Masters or Bachelor comp-sci course. Different people have different views on this, of course. Yeah, actually, I have to agree

Re: [Haskell-cafe] List operation question

2007-02-05 Thread ihope
On 2/4/07, Eric Olander [EMAIL PROTECTED] wrote: Hi, I'm still somewhat new to Haskell, so I'm wondering if there are better ways I could implement the following functions, especially shiftl: moves the last element to the head of the list shiftl :: [a] - [a] shiftl [] = []

[Haskell-cafe] Re: nested maybes

2007-02-05 Thread Benjamin Franksen
Udo Stenzel wrote: Sure, you're right, everything flowing in the same direction is usually nicer, and in central Europe, that order is from the left to the right. What a shame that the Haskell gods chose to give the arguments to (.) and ($) the wrong order! But then application is in the

[Haskell-cafe] Final issues to fix for the shootout entries (Was: no subject)

2007-02-05 Thread Donald Bruce Stewart
Yeah, have a look on the shootout: http://shootout.alioth.debian.org/gp4/benchmark.php?test=recursivelang=all Has an ackerman. More detailed comparisions, across the 19 benchmarks on the shootout, with notes on which of the 19 GHC Haskell is significantly slower (4x) at: Haskell verus

[Haskell-cafe] A function callable from C

2007-02-05 Thread John Ky
Hi, The following code works: type ServiceMainClosure = DWORD - IO () foreign import ccall wrapper mkServiceMainClosure :: ServiceMainClosure - IO (FunPtr ServiceMainClosure) But the following doesn't: type ServiceMainClosure = DWORD - [String] - IO () foreign import ccall wrapper

Re: [Haskell-cafe] A function callable from C

2007-02-05 Thread Stefan O'Rear
On Tue, Feb 06, 2007 at 12:33:58PM +1100, John Ky wrote: Hi, The following code works: type ServiceMainClosure = DWORD - IO () foreign import ccall wrapper mkServiceMainClosure :: ServiceMainClosure - IO (FunPtr ServiceMainClosure) But the following doesn't: type

Re: [Haskell-cafe] A function callable from C

2007-02-05 Thread John Ky
Hi Stefan, In that case, how do I marshall [String] to Ptr (Ptr CChar)? Thanks -John On 2/6/07, Stefan O'Rear [EMAIL PROTECTED] wrote: You have to use a type that C's tiny brain understains. IANAWP but I'm guessing you want: type ServiceMainClosure = DWORD - Ptr (Ptr CChar) - IO ()

Re: [Haskell-cafe] A function callable from C

2007-02-05 Thread Stefan O'Rear
On Tue, Feb 06, 2007 at 12:40:38PM +1100, John Ky wrote: Hi Stefan, In that case, how do I marshall [String] to Ptr (Ptr CChar)? look at Foreign.C.String and Foreign.Ptr ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

Re: [Haskell-cafe] A function callable from C

2007-02-05 Thread John Ky
Actually, what I need to do is a fair bit more complex than string marshalling. It feels like I'll need to pull together a number of different concepts so I may as well describe the problem directly. The C function I want to call is StartServiceCtrlDispatcher: *BOOL*

[Haskell-cafe] Trouble representing a set of flags

2007-02-05 Thread Stefan O'Rear
I have a structure: data Attr = Attr { fg :: !Color, bg :: !Color, bold :: !Bool, blink :: !Bool, rv :: !Bool, halfBright :: !Bool, underline :: !Bool }

Re: [Haskell-cafe] How is laziness defined?

2007-02-05 Thread ajb
G'day all. Quoting Matthew Brecknell [EMAIL PROTECTED]: Although it covers irrefutable (lazy) pattern matching in the second section, it does appear to miss the point that let bindings are always irrefutable. Thus, there is no difference between these two: let (x,y) = foo in ... let

Re: [Haskell-cafe] List operation question

2007-02-05 Thread Eric Olander
That's a clever routine. It should be faster than mine since it only makes a single pass though the list. Thanks for all the suggestions from everyone that responded. Here is a link to some more info on the project I'm working on if anyone is interested: http://ehaskell.blogspot.com/ -Eric

Re: [Haskell-cafe] How is laziness defined?

2007-02-05 Thread Matthew Brecknell
I said: Although it covers irrefutable (lazy) pattern matching in the second section, it does appear to miss the point that let bindings are always irrefutable. Thus, there is no difference between these two: let (x,y) = foo in ... let ~(x,y) = foo in ... Andrew Bromage said: let (x,())

Re: [Haskell-cafe] How is laziness defined?

2007-02-05 Thread ajb
G'day all. Quoting Matthew Brecknell [EMAIL PROTECTED]: In other words, the irrefutability of a pattern match does not distribute inside the top-level data constructor of the pattern. I wasn't disagreeing with you, which is why I didn't comment. Note also that if Haskell prime incorporates

Re: [Haskell-cafe] Re: nested maybes

2007-02-05 Thread Udo Stenzel
Benjamin Franksen wrote: Udo Stenzel wrote: Sure, you're right, everything flowing in the same direction is usually nicer, and in central Europe, that order is from the left to the right. What a shame that the Haskell gods chose to give the arguments to (.) and ($) the wrong order! But