Re: [Haskell-cafe] Re: A free monad theorem?

2006-09-01 Thread Andrea Rossato
Il Fri, Sep 01, 2006 at 07:22:02AM +0200, Tomasz Zielonka ebbe a scrivere: > On Fri, Sep 01, 2006 at 01:13:14AM +0200, Benjamin Franksen wrote: > > So getting the value out of the monad is not a pure function (extract :: > > Monad m => m a -> a). I think I stated that, already, in my previous post.

Re[2]: [Haskell-cafe] state and exception or types again...

2006-09-01 Thread Bulat Ziganshin
Hello Andrea, Thursday, August 31, 2006, 4:22:49 PM, you wrote: > The tutorial will have this outline: first we build a monad adding > output, exception, and state. Then we use monad transformer to take > out state and output and add debug, doing lifting, put(ing) and > get(ing) by hand, to under

Re: [Haskell-cafe] A free monad theorem?

2006-09-01 Thread Bulat Ziganshin
Hello Benjamin, Thursday, August 31, 2006, 9:23:55 PM, you wrote: > The background for my question is an argument I had some time ago with > someone about what the 'real nature' of monads is. He argued that monads > are mainly about 'chaining' (somehow wrapped up) values in an associative > way,

Re: [Haskell-cafe] Re: A free monad theorem?

2006-09-01 Thread Bulat Ziganshin
Hello Benjamin, Friday, September 1, 2006, 3:13:14 AM, you wrote: > The real question (the one that bugs me, anyway) is if one can give a > precise meaning to the informal argument that if the definition of bind is > to be non-trivial then its second argument must be applied to some > non-trivial

Re: [Haskell-cafe] state and exception or types again...

2006-09-01 Thread Andrea Rossato
Il Fri, Sep 01, 2006 at 10:43:14AM +0400, Bulat Ziganshin ebbe a scrivere: > > The tutorial will have this outline: first we build a monad adding > > output, exception, and state. Then we use monad transformer to take > > out state and output and add debug, doing lifting, put(ing) and > > get(ing)

Re: [Haskell-cafe] Re: data structures question

2006-09-01 Thread Tamas K Papp
On Thu, Aug 31, 2006 at 11:09:07AM +0400, Bulat Ziganshin wrote: > Hello Benjamin, > > Wednesday, August 30, 2006, 11:40:09 PM, you wrote: > > > Matthias Fischmann wrote: > >> The trick is that Int is not the only index data type, but tuples of > >> index data types are, too. Do this: > >> > >>

Re: [Haskell-cafe] Re: A free monad theorem?

2006-09-01 Thread Brian Hulley
Benjamin Franksen wrote: Tomasz Zielonka wrote: whatever you do, you won't be able to extract an 'a' typed value, non-bottom from this computation. Cont is defined as: newtype Cont r a = Cont {runCont :: (a -> r) -> r)} So getting the value out of the monad is not

Re: [Haskell-cafe] Re: A free monad theorem?

2006-09-01 Thread Tomasz Zielonka
On Fri, Sep 01, 2006 at 07:22:02AM +0200, Tomasz Zielonka wrote: > > The real question (the one that bugs me, anyway) is if one can give a > > precise meaning to the informal argument that if the definition of bind is > > to be non-trivial then its second argument must be applied to some > > non-tr

[Haskell-cafe] Rewriting a Python application to Haskell

2006-09-01 Thread basvandijk
Hello, The company I work for [1] develops highly sensitive trace gas detectors. We also develop software that is used to control these detectors from a PC or laptop. With this software a user can setup an experiment, execute it and analyse and visualise the data in real-time. While executing,

Re: [Haskell-cafe] Rewriting a Python application to Haskell

2006-09-01 Thread Neil Mitchell
Hi 1) I would like to know if its difficult to use wxHaskell and STM side by side and if there are any issues I need to know about. I have no idea about wxHaskell and STM, but I found out that hard way that Gtk2Hs + threads = bad idea. Depending on the machine I used, I got a wide class of un

[Haskell-cafe] Exercise in point free-style

2006-09-01 Thread Julien Oster
Hello, I was just doing Exercise 7.1 of Hal Daumé's very good "Yet Another Haskell Tutorial". It consists of 5 short functions which are to be converted into point-free style (if possible). It's insightful and after some thinking I've been able to come up with solutions that make me understa

Re: [Haskell-cafe] Exercise in point free-style

2006-09-01 Thread Julien Oster
Julien Oster wrote: But I'm having problems with one of the functions: func3 f l = l ++ map f l While we're at it: The best thing I could come up for func2 f g l = filter f (map g l) is func2p f g = (filter f) . (map g) Which isn't exactly point-_free_. Is it possible to reduce that furth

Re: [Haskell-cafe] Exercise in point free-style

2006-09-01 Thread Neil Mitchell
Hi Julien, func3 f l = l ++ map f l func3 f = ap (++) (map f) func3 = ap (++) . map Looks pretty clear and simple. However, I can't come up with a solution. Is it even possible to remove one of the variables, f or l? If so, how? I have no idea how to do this - the solution is to log into #ha

Re: [Haskell-cafe] Exercise in point free-style

2006-09-01 Thread Neil Mitchell
Hi func2 f g l = filter f (map g l) is func2p f g = (filter f) . (map g) func2 = (. map) . (.) . filter Again, how anyone can come up with a solution like this, is entirely beyond me... Thanks Neil ___ Haskell-Cafe mailing list Haskell-Cafe@haskel

Re: [Haskell-cafe] Exercise in point free-style

2006-09-01 Thread Robert Dockins
On Friday 01 September 2006 11:44, Neil Mitchell wrote: > Hi > > > func2 f g l = filter f (map g l) > > is > > func2p f g = (filter f) . (map g) > > func2 = (. map) . (.) . filter > > Again, how anyone can come up with a solution like this, is entirely > beyond me... To answer part of the OP's que

[Haskell-cafe] Are associated types synonyms like type classes?

2006-09-01 Thread Brian Smith
I read the easy parts of the "Associated Types with Class" and "Associated Type Synonyms" papers. An associated type synonym seems to kind of work similarly to a restricted form of class. In what way are the two following examples different?     -- define a class with a type synonym, and a set of o

Re[2]: [Haskell-cafe] Re: data structures question

2006-09-01 Thread Bulat Ziganshin
Hello Tamas, Friday, September 1, 2006, 1:52:03 PM, you wrote: >> >> | type Point = (State, State, Int) >> > | type TypeV = Array Point Double >> >> which will require 128 gigs of memory for 32-bit cpus and even >> slightly more for 64-bit ones :) > Bulat, > Can you please explain this? The f

[Haskell-cafe] Re: Exercise in point free-style

2006-09-01 Thread John Hughes
From: Julien Oster <[EMAIL PROTECTED]> Subject: [Haskell-cafe] Exercise in point free-style I was just doing Exercise 7.1 of Hal Daumé's very good "Yet Another Haskell Tutorial". It consists of 5 short functions which are to be converted into point-free style (if possible). It's insightful and a

Re: [Haskell-cafe] Are associated types synonyms like type classes?

2006-09-01 Thread Stefan Holdermans
Brian, I read the easy parts of the "Associated Types with Class" and "Associated Type Synonyms" papers. An associated type synonym seems to kind of work similarly to a restricted form of class. In what way are the two following examples different? -- define a class with a type synony

Re: [Haskell-cafe] Exercise in point free-style

2006-09-01 Thread Udo Stenzel
Julien Oster wrote: > While we're at it: The best thing I could come up for > > func2 f g l = filter f (map g l) > > is > > func2p f g = (filter f) . (map g) > > Which isn't exactly point-_free_. Is it possible to reduce that further? Sure it is: func2 f g l = filter f (map g l) func2 f g = (

Re: [Haskell-cafe] Are associated types synonyms like type classes?

2006-09-01 Thread Bulat Ziganshin
Hello Brian, Friday, September 1, 2006, 8:32:55 PM, you wrote: > I read the easy parts of the "Associated Types with Class" and > "Associated Type Synonyms" papers. An associated type synonym seems > to kind of work similarly to a restricted form of class. In what way > are the two following exam

[Haskell-cafe] getContents and lazy evaluation

2006-09-01 Thread Tamas K Papp
Hi, I am newbie, reading the Gentle Introduction. Chapter 7 (Input/Output) says Pragmatically, it may seem that getContents must immediately read an entire file or channel, resulting in poor space and time performance under certain conditions. However, this is not the case. The key point

Re: [Haskell-cafe] getContents and lazy evaluation

2006-09-01 Thread Robert Dockins
On Friday 01 September 2006 15:19, Tamas K Papp wrote: > Hi, > > I am newbie, reading the Gentle Introduction. Chapter 7 > (Input/Output) says > > Pragmatically, it may seem that getContents must immediately read an > entire file or channel, resulting in poor space and time performance > und

Re: [Haskell-cafe] getContents and lazy evaluation

2006-09-01 Thread Duncan Coutts
On Fri, 2006-09-01 at 16:28 -0400, Robert Dockins wrote: > On Friday 01 September 2006 15:19, Tamas K Papp wrote: > > Hi, > > > > I am newbie, reading the Gentle Introduction. Chapter 7 > > (Input/Output) says > > > > Pragmatically, it may seem that getContents must immediately read an > > ent

Re: [Haskell-cafe] getContents and lazy evaluation

2006-09-01 Thread Robert Dockins
On Friday 01 September 2006 16:46, Duncan Coutts wrote: > On Fri, 2006-09-01 at 16:28 -0400, Robert Dockins wrote: > > On Friday 01 September 2006 15:19, Tamas K Papp wrote: > > > Hi, > > > > > > I am newbie, reading the Gentle Introduction. Chapter 7 > > > (Input/Output) says > > > > > > Pragma

Re: [Haskell-cafe] getContents and lazy evaluation

2006-09-01 Thread Donn Cave
On Fri, 1 Sep 2006, Robert Dockins wrote: > On Friday 01 September 2006 16:46, Duncan Coutts wrote: ... >> Note also, that with lazy IO we can write really short programs that are >> blindingly quick. Lazy IO allows us to save a copy through the Handle >> buffer. (Never understood why some people

Re: [Haskell-cafe] getContents and lazy evaluation

2006-09-01 Thread Robert Dockins
On Friday 01 September 2006 18:01, Donn Cave wrote: > On Fri, 1 Sep 2006, Robert Dockins wrote: > > On Friday 01 September 2006 16:46, Duncan Coutts wrote: > > ... > > >> Note also, that with lazy IO we can write really short programs that are > >> blindingly quick. Lazy IO allows us to save a copy

Re: [Haskell-cafe] getContents and lazy evaluation

2006-09-01 Thread Duncan Coutts
On Fri, 2006-09-01 at 17:36 -0400, Robert Dockins wrote: > Perhaps I should be more clear. When I said "advanced" above I meant "any > use > whereby you treat a file as random access, read/write storage, or do any kind > of directory manipulation (including deleting and or renaming files)". L

Re: [Haskell-cafe] getContents and lazy evaluation

2006-09-01 Thread Julien Oster
Duncan Coutts wrote: Hi, > In practise I expect that most programs that deal with file IO strictly > do not handle the file disappearing under them very well either. At best > the probably throw an exception and let something else clean up. And at least in Unix world, they just don't disappear.

Re: [Haskell-cafe] Exercise in point free-style

2006-09-01 Thread Julien Oster
Udo Stenzel wrote: Thank you all a lot for helping me, it's amazing how quickly I received these detailed answers! > func2 f g l = filter f (map g l) > func2 f g = (filter f) . (map g) -- definition of (.) > func2 f g = ((.) (filter f)) (map g) -- desugaring > func2 f = ((.) (filter f)) . m

Re: [Haskell-cafe] Re: Exercise in point free-style

2006-09-01 Thread Lennart Augustsson
An easy way to solve this is to ask lambdabot. Log on to the Haskell IRC channel: lennart: @pl \ f l -> l ++ map f l lambdabot: ap (++) . map Notice how it's much shorter than the Hughes' solution. :) -- Lennart On Sep 1, 2006, at 13:11 , John Hughes wrote: From: Julien Oster <[EM

Re: [Haskell-cafe] Re: Exercise in point free-style

2006-09-01 Thread Thomas Davie
Shorter, although perhaps less insightful. Bob On 2 Sep 2006, at 01:36, Lennart Augustsson wrote: An easy way to solve this is to ask lambdabot. Log on to the Haskell IRC channel: lennart: @pl \ f l -> l ++ map f l lambdabot: ap (++) . map Notice how it's much shorter than the Hughes' sol

Re: [Haskell-cafe] Exercise in point free-style

2006-09-01 Thread Julien Oster
Julien Oster wrote: > = ((.) (filter f)) . map g l > = (.)((.) . filter f)(map) g l -- desugaring > = (.map)((.) . filter f) g l -- sweeten up > = (.map) . (.) . filter g l-- definition of (.) By the way, I think from now on, when doing point-free-ify

Re: [Haskell-cafe] Exercise in point free-style

2006-09-01 Thread Donald Bruce Stewart
haskell: > Hello, > > I was just doing Exercise 7.1 of Hal Daum?'s very good "Yet Another > Haskell Tutorial". It consists of 5 short functions which are to be > converted into point-free style (if possible). > > It's insightful and after some thinking I've been able to come up with > solution

Re: [Haskell-cafe] Exercise in point free-style

2006-09-01 Thread Donald Bruce Stewart
haskell: > Julien Oster wrote: > > >But I'm having problems with one of the functions: > > > >func3 f l = l ++ map f l > > While we're at it: The best thing I could come up for > > func2 f g l = filter f (map g l) > > is > > func2p f g = (filter f) . (map g) > > Which isn't exactly point-_fre

Re: [Haskell-cafe] getContents and lazy evaluation

2006-09-01 Thread Donn Cave
Quoth Julien Oster <[EMAIL PROTECTED]>: ... | But what happens when two processes use the same file and one process is | writing into it using lazy IO which didn't happen yet? The other process | wouldn't see its changes yet. That's actually a much more general problem, one that I imagine applies