Re: [Haskell-cafe] automatically inserting type declarations

2009-04-07 Thread Brandon S. Allbery KF8NH
On 2009 Apr 6, at 23:06, FFT wrote: I remember hearing about a Haskell mode for Vim, Emacs, Yi or VisualHaskell that inserts type declarations automatically (it's lazier to just check the type than to write it manually), but I can't remember any details. What editor mode / IDE was it? I think

Re: [Haskell-cafe] Generating arbitrary function in QuickCheck

2009-04-07 Thread Janis Voigtlaender
Jason Dagit wrote: On Mon, Apr 6, 2009 at 10:09 PM, Eugene Kirpichov ekirpic...@gmail.com wrote: Since the argument to sortBy must impose a linear ordering on its arguments, and any linear ordering may as well be generated by assigning an integer to each element of type 'a', and your sorting

Re: [Haskell-cafe] replicateM should be called mreplicate?

2009-04-07 Thread Thomas Davie
On 7 Apr 2009, at 07:37, David Menendez wrote: On Mon, Apr 6, 2009 at 1:46 PM, Luke Palmer lrpal...@gmail.com wrote: On Mon, Apr 6, 2009 at 11:42 AM, David Menendez d...@zednenem.com wrote: Of course, this suggests that mfix should be fixM, so perhaps a better distinction is that mplus

[Haskell-cafe] tail recursion

2009-04-07 Thread Daryoush Mehrtash
Is the call to go in the following code considered as tail recursion? data DList a = DLNode (DList a) a (DList a) mkDList :: [a] - DList a mkDList [] = error http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:error must have at least one element mkDList xs = let (first,last

Re: [Haskell-cafe] automatically inserting type declarations

2009-04-07 Thread Claus Reinke
I remember hearing about a Haskell mode for Vim, Emacs, Yi or VisualHaskell that inserts type declarations automatically (it's lazier to just check the type than to write it manually), but I can't remember any details. What editor mode / IDE was it? As far as I know, my haskellmode plugins for

Re: [Haskell-cafe] Monad transformer to consume a list

2009-04-07 Thread Henning Thielemann
On Tue, 7 Apr 2009, Stephan Friedrichs wrote: Henning Thielemann wrote: is there a monad transformer to consume an input list? I've got external events streaming into the monad that are consumed on demand and I'm not sure if there's something better than a StateT. I wondered that, too. I

[Haskell-cafe] Re: Configuring cabal dependencies at install-time

2009-04-07 Thread John Lato
From: Jeff Heard jefferson.r.he...@gmail.com Is there a way to do something like autoconf and configure dependencies at install time?  Building buster, I keep adding dependencies and I'd like to keep that down to a minimum without the annoyance of littering Hackage with dozens of packages.  

[Haskell-cafe] UPDATE: haskellmode for Vim now at projects.haskell.org (+screencast; -)

2009-04-07 Thread Claus Reinke
I have become aware that many Haskellers are not aware of the Haskell mode plugins for Vim, in spite of the 100 downloads per month I saw when I last checked. Since the plugins have just completed their move to their new home at http://projects.haskell.org/haskellmode-vim/ this seems to be a

Re: [Haskell-cafe] Re: Configuring cabal dependencies at install-time

2009-04-07 Thread Martijn van Steenbergen
John Lato wrote: From: Jeff Heard jefferson.r.he...@gmail.com Is there a way to do something like autoconf and configure dependencies at install time? Building buster, I keep adding dependencies and I'd like to keep that down to a minimum without the annoyance of littering Hackage with dozens

Re: [Haskell-cafe] strange performance issue with takusen 0.8.3

2009-04-07 Thread Alistair Bayley
2009/4/6 Marko Schütz markoschu...@web.de: I have an application where some simple data extracted from some source files is inserted into a PostgreSQL database. The application uses Takusen and is compiled with GHC 6.8.3. Some (59 in the test data) of the selects take on average 460ms each

Re: [Haskell-cafe] UPDATE: haskellmode for Vim now at projects.haskell.org (+screencast; -)

2009-04-07 Thread Matthijs Kooijman
Hi Claus, http://projects.haskell.org/haskellmode-vim/ The download link on this page seems to use \ instead of /, making it not work. For anyone eager to download it, just replace \ (or %5C) in your address bar with \ and it should work. Gr. Matthijs signature.asc Description: Digital

Re: [Haskell-cafe] tail recursion

2009-04-07 Thread wren ng thornton
Daryoush Mehrtash wrote: Is the call to go in the following code considered as tail recursion? data DList a = DLNode (DList a) a (DList a) mkDList :: [a] - DList a mkDList [] = error must have at least one element mkDList xs = let (first,last) = go last xs first in first

Re: [Haskell-cafe] Strange type error with associated type synonyms

2009-04-07 Thread Manuel M T Chakravarty
Matt Morrow: On Mon, Apr 6, 2009 at 7:39 PM, Manuel M T Chakravarty c...@cse.unsw.edu.au wrote: Peter Berry: 3) we apply appl to x, so Memo d1 a = Memo d a. unify d = d1 But for some reason, step 3 fails. Step 3 is invalid - cf,

[Haskell-cafe] threadDelay granularity

2009-04-07 Thread Ulrik Rasmussen
Hello. I am writing a simple game in Haskell as an exercise, and in the rendering loop I want to cap the framerate to 60fps. I had planned to do this with GHC.Conc.threadDelay, but looking at it's documentation, I discovered that it can only delay the thread in time spans that are multiples of

[Haskell-cafe] advice on space efficient data structure with efficient snoc operation

2009-04-07 Thread Manlio Perillo
Hi. I'm still working on my Netflix Prize project. For a function I wrote, I really need a data structure that is both space efficient (unboxed elements) and with an efficient snoc operation. I have pasted a self contained module with the definition of the function I'm using:

Re: [Haskell-cafe] UPDATE: haskellmode for Vim now atprojects.haskell.org (+screencast; -)

2009-04-07 Thread Claus Reinke
http://projects.haskell.org/haskellmode-vim/ The download link on this page seems to use \ instead of /, making it not work. For anyone eager to download it, just replace \ (or %5C) in your address bar with \ and it should work. argh, thanks, now fixed (filename completion in Vim, :help

Re: [Haskell-cafe] UPDATE: haskellmode for Vim now at projects.haskell.org (+screencast; -)

2009-04-07 Thread Matthijs Kooijman
Hi Claus, I've installed the vimball, and it spit a few errors at me. In particular, it couldn't find the haddock documentation directory. A quick look at haskell_doc.vim shows that it should autodetect the directory. However, for some reason my ghc-pkg command returns the doc directory twice:

Re: [Haskell-cafe] Monad transformer to consume a list

2009-04-07 Thread Stephan Friedrichs
Henning Thielemann wrote: is there a monad transformer to consume an input list? I've got external events streaming into the monad that are consumed on demand and I'm not sure if there's something better than a StateT. I wondered that, too. I wondered whether there is something inverse to

[Haskell-cafe] Re: Parallel combinator, performance advice

2009-04-07 Thread ChrisK
You create one MVar for each task in order to ensure all the tasks are done. This is pretty heavyweight. You could create a single Control.Concurrent.QSemN to count the completed tasks, starting with 0. Each task is followed by signalQSemN with a value of 1. (I would use finally). As

Re: [Haskell-cafe] Strange type error with associated type synonyms

2009-04-07 Thread Matt Morrow
On Mon, Apr 6, 2009 at 7:39 PM, Manuel M T Chakravarty c...@cse.unsw.edu.au wrote: Peter Berry: 3) we apply appl to x, so Memo d1 a = Memo d a. unify d = d1 But for some reason, step 3 fails. Step 3 is invalid - cf, http://www.haskell.org/pipermail/haskell-cafe/2009-April/059196.html.

[Haskell-cafe] Parallel combinator, performance advice

2009-04-07 Thread Neil Mitchell
Hi, I've written a parallel_ function, code attached. I'm looking for criticism, suggestions etc on how to improve the performance and fairness of this parallel construct. (If it turns out this construct is already in a library somewhere, I'd be interested in that too!) The problem I'm trying to

Re: [Haskell-cafe] Parallel combinator, performance advice

2009-04-07 Thread Bulat Ziganshin
Hello Neil, Tuesday, April 7, 2009, 2:25:12 PM, you wrote: The problem I'm trying to solve is running system commands in parallel. system commands means execution of external commands or just system calls inside Haskell? Running a benchmark of issuing 1 million trivial tasks (create,

Re: [Haskell-cafe] threadDelay granularity

2009-04-07 Thread Peter Verswyvelen
I think this is an RTS option. http://www.haskell.org/ghc/docs/latest/html/users_guide/using-concurrent.html On Tue, Apr 7, 2009 at 1:41 PM, Ulrik Rasmussen hask...@utr.dk wrote: Hello. I am writing a simple game in Haskell as an exercise, and in the rendering loop I want to cap the

Re: [Haskell-cafe] Monad transformer to consume a list

2009-04-07 Thread Tom Schrijvers
Hello, is there a monad transformer to consume an input list? I've got external events streaming into the monad that are consumed on demand and I'm not sure if there's something better than a StateT. I wondered that, too. I wondered whether there is something inverse to Writer, and Reader is

Re: [Haskell-cafe] System.Process.Posix

2009-04-07 Thread John Goerzen
Bulat Ziganshin wrote: Hello Cristiano, Sunday, April 5, 2009, 12:05:02 AM, you wrote: Is it me or the above package is not included in Hoogle? afair, Neil, being windows user, includes only packages available for his own system there was a large thread a few months ago and many

Re: [Haskell-cafe] Re: Configuring cabal dependencies at install-time

2009-04-07 Thread John Dorsey
John Lato wrote: I think that the proper solution is to break up libraries into separate packages as Jeff suggests (buster, buster-ui, etc.), but then the total packages on hackage would explode. I don't feel great about I thought about this a while back and came to the conclusion that the

Re: [Haskell-cafe] UPDATE: haskellmode for Vim now atprojects.haskell.org (+screencast; -)

2009-04-07 Thread Claus Reinke
Hi Matthijs, I've installed the vimball, and it spit a few errors at me. In particular, it couldn't find the haddock documentation directory. A quick look at haskell_doc.vim shows that it should autodetect the directory. However, for some reason my ghc-pkg command returns the doc directory

[Haskell-cafe] Re: Parallel combinator, performance advice

2009-04-07 Thread ChrisK
Neil Mitchell wrote: Sorry, accidentally sent before finishing the response! I also noticed you sent this directly to me, not to -cafe, was that intentional? The mail/news gateway makes it look like that, but I also sent to the mailing list. You mean something like: parallel_ xs = sem

Re: [Haskell-cafe] UPDATE: haskellmode for Vim now at projects.haskell.org (+screencast; -)

2009-04-07 Thread Matthijs Kooijman
Hi Claus, I've found two more little bugs. The first is that version comparison is incorrect. It now requires that all components are greater, so comparing 6.10.1 = 6.8.2 returns false (since 1 2). Also, there is a ghc-pkg field * haddock-html call, but here the * will be expanded by the shell

Re: [Haskell-cafe] System.Process.Posix

2009-04-07 Thread Jonathan Cast
On Tue, 2009-04-07 at 14:31 +0100, Neil Mitchell wrote: Hi Is it me or the above package is not included in Hoogle? afair, Neil, being windows user, includes only packages available for his own system there was a large thread a few months ago and many peoples voted for excluding

Re: [Haskell-cafe] Strange type error with associated type synonyms

2009-04-07 Thread Claus Reinke
Basically, type checking proceeds in one of two modes: inferring or checking. The former is when there is no signature is given; the latter, if there is a user-supplied signature. GHC can infer ambiguous signatures, but it cannot check them. This is of course very confusing and we need

Re: [Haskell-cafe] System.Process.Posix

2009-04-07 Thread Neil Mitchell
Hi Is it me or the above package is not included in Hoogle? afair, Neil, being windows user, includes only packages available for his own system there was a large thread a few months ago and many peoples voted for excluding any OS-specific packages at all since this decreases portability

Re: [Haskell-cafe] System.Process.Posix

2009-04-07 Thread Cristiano Paris
On Tue, Apr 7, 2009 at 3:31 PM, Neil Mitchell ndmitch...@gmail.com wrote: I was implementing full package support last weekend. With any luck, I'll manage to push the changes tonight. If not, I'll push them as soon as I get back from holiday (a week or so) Thank you, Neil. Cristiano

Re: [Haskell-cafe] UPDATE: haskellmode for Vim now atprojects.haskell.org (+screencast; -)

2009-04-07 Thread Claus Reinke
Matthijs, thanks for the reports, and analyses and suggested patches are even better! We should probably take this offlist at some point, though. I've found two more little bugs. The first is that version comparison is incorrect. It now requires that all components are greater, so comparing

Re: [Haskell-cafe] Re: Configuring cabal dependencies at install-time

2009-04-07 Thread Edward Kmett
This has been a lot on my mind lately as my current library provides additional functionality to data types from a wide array of other packages. I face a version of Wadler's expression problem. I provide a set of classes for injecting into monoids/seminearrings/etc. to allow for quick reductions

[Haskell-cafe] Re: Parallel combinator, performance advice

2009-04-07 Thread Neil Mitchell
Hi The problem I'm trying to solve is running system commands in parallel. system commands means execution of external commands or just system calls inside Haskell? Calls to System.Cmd.system, i.e. running external console processes. It's a make system I'm writing, so virtually all the

Re: [Haskell-cafe] threadDelay granularity

2009-04-07 Thread Ulrik Rasmussen
On Tue, Apr 07, 2009 at 04:01:01PM +0200, Peter Verswyvelen wrote: Are you on Windows? Because this might be because GHC is not using a high resolution timer for doing its scheduling, I don't know... No, Ubuntu 8.10. That may very well be, I'm not that much into the details of GHC. I'm

Re: [Haskell-cafe] threadDelay granularity

2009-04-07 Thread Peter Verswyvelen
Do you want to cap the rendering framerate at 60FPS or the animation framerate? Because when you use OpenGL and GLFW, you can just GLFW.swapInterval $= 1 to cap the rendering framerate at the refresh rate of your monitor or LCD screen (usually 60Hz) On Tue, Apr 7, 2009 at 1:41 PM, Ulrik

Re: [Haskell-cafe] advice on space efficient data structure with efficient snoc operation

2009-04-07 Thread Edward Kmett
I'm in the process of adding a Data.Sequence.Unboxed to unboxed-containers. I hope to have it in hackage today or tomorrow, should its performance work out as well as Data.Set.Unboxed. Be warned the API will likely be shifting on you for a little while, while I figure out a better way to manage

RE: [Haskell-cafe] Strange type error with associated type synonyms

2009-04-07 Thread Simon Peyton-Jones
| Here is a variation to make this point clearer: | | {-# LANGUAGE NoMonomorphismRestriction #-} | {-# LANGUAGE TypeFamilies, ScopedTypeVariables #-} | | class Fun d where | type Memo d :: * - * | abst :: (d - a) - Memo d a | appl :: Memo d a - (d - a) | | f = abst . appl | | -- f' ::

[Haskell-cafe] CFP: JFP Special Issue on Generic Programming

2009-04-07 Thread Matthew Fluet (ICFP Publicity Chair)
OPEN CALL FOR PAPERS JFP Special Issue on Generic Programming Deadline: 1 October 2009 http://www.comlab.ox.ac.uk/ralf.hinze/JFP/cfp.html Scope - Generic programming is about making programs more

[Haskell-cafe] Re[2]: Parallel combinator, performance advice

2009-04-07 Thread Bulat Ziganshin
Hello Neil, Tuesday, April 7, 2009, 6:13:29 PM, you wrote: Calls to System.Cmd.system, i.e. running external console processes. It's a make system I'm writing, so virtually all the time is spent in calls to ghc etc. To Bulat: I should have been clearer with the spec. The idea is that

Re: [Haskell-cafe] Strange type error with associated type synonyms

2009-04-07 Thread Peter Berry
On 07/04/2009, Ryan Ingram ryani.s...@gmail.com wrote: On Mon, Apr 6, 2009 at 2:36 PM, Peter Berry pwbe...@gmail.com wrote: As I understand it, the type checker's thought process should be along these lines: 1) the type signature dictates that x has type Memo d a. 2) appl has type Memo d1 a

Re: [Haskell-cafe] Strange type error with associated type synonyms

2009-04-07 Thread Claus Reinke
| Here is a variation to make this point clearer: | | {-# LANGUAGE NoMonomorphismRestriction #-} | {-# LANGUAGE TypeFamilies, ScopedTypeVariables #-} | | class Fun d where | type Memo d :: * - * | abst :: (d - a) - Memo d a | appl :: Memo d a - (d - a) | | f = abst . appl | | -- f' ::

[Haskell-cafe] Re[3]: Parallel combinator, performance advice

2009-04-07 Thread Bulat Ziganshin
Hello Bulat, Tuesday, April 7, 2009, 6:50:14 PM, you wrote: tid - forkIO (executing commands from chan...) waitQSem sem killThread tid instead of killThread we really should send pseudo-job (like my Nothing value) that will led to self-killing of job that gets this signal this

[Haskell-cafe] Re: Parallel combinator, performance advice

2009-04-07 Thread ChrisK
Neil Mitchell wrote: I guess the nested calls to parallel_ bit is the part of the spec that makes everything much harder! Thanks Neil Yes. Much more annoying. But the problem here is generic. To avoid it you must never allow all thread to block at once. The parallel_ function is

Re: [Haskell-cafe] Parallel combinator, performance advice

2009-04-07 Thread Sebastian Sylvan
This is a random idea, that's probably not going to work, but I don't have a way of testing it so I'll just post it! How about using unsafeInterleaveIO to get a lazy suspension of the result of each action, and then using par to spark off each of them? If that works you can reuse the existing

Re: [Haskell-cafe] advice on space efficient data structure with efficient snoc operation

2009-04-07 Thread Manlio Perillo
Edward Kmett ha scritto: I'm in the process of adding a Data.Sequence.Unboxed to unboxed-containers. I hope to have it in hackage today or tomorrow, should its performance work out as well as Data.Set.Unboxed. Looking at the data definition of Data.Sequence I suspect that it is not really

Re: [Haskell-cafe] Strange type error with associated type synonyms

2009-04-07 Thread Peter Berry
On Mon, Apr 6, 2009 at 7:39 PM, Manuel M T Chakravarty c...@cse.unsw.edu.au wrote: Peter Berry: 3) we apply appl to x, so Memo d1 a = Memo d a. unify d = d1 But for some reason, step 3 fails. Step 3 is invalid - cf, http://www.haskell.org/pipermail/haskell-cafe/2009-April/059196.html.

[Haskell-cafe] Re[2]: Parallel combinator, performance advice

2009-04-07 Thread Bulat Ziganshin
Hello Neil, Tuesday, April 7, 2009, 6:13:29 PM, you wrote: Consider a thread pool with 2 threads and the call parallel_ [parallel_ [b,c],a] You get the sequence: enqueue (parallel_ [b,c]) a wait on parallel_ [b,c] While you are executing a, a thread pool starts: enqueue b c wait for

Re: [Haskell-cafe] threadDelay granularity

2009-04-07 Thread Ulrik Rasmussen
On Tue, Apr 07, 2009 at 04:34:22PM +0200, Peter Verswyvelen wrote: Do you want to cap the rendering framerate at 60FPS or the animation framerate? Because when you use OpenGL and GLFW, you can just GLFW.swapInterval $= 1 to cap the rendering framerate at the refresh rate of your monitor

[Haskell-cafe] Re: Re[2]: Parallel combinator, performance advice

2009-04-07 Thread Neil Mitchell
Hi Sebastian: How about using unsafeInterleaveIO to get a lazy suspension of the result of each action, and then using par to spark off each of them? If that works you can reuse the existing task-parallel system of GHC to do the heavily lifting for you, instead of having to write your

[Haskell-cafe] Re[2]: Parallel combinator, performance advice

2009-04-07 Thread Bulat Ziganshin
Hello Neil, Tuesday, April 7, 2009, 6:13:29 PM, you wrote: Calls to System.Cmd.system, i.e. running external console processes. It's a make system I'm writing, so virtually all the time is spent in calls to ghc etc. btw, if all that you need is to limit amount of simultaneous

[Haskell-cafe] Re: Re[2]: Parallel combinator, performance advice

2009-04-07 Thread Neil Mitchell
Hi Bulat, btw, if all that you need is to limit amount of simultaneous System.Cmd.system calls, you may go from opposite side: wrap this call into semaphore: sem = unsafePerformIO$ newQSem numCapabilities mysystem = bracket_ (waitQSem sem) (signalQSem sem) . system and implement para as

[Haskell-cafe] Re[4]: Parallel combinator, performance advice

2009-04-07 Thread Bulat Ziganshin
Hello Neil, Tuesday, April 7, 2009, 7:33:25 PM, you wrote: How about using unsafeInterleaveIO to get a lazy suspension of the result of each action, and then using par to spark off each of them? If that works you can reuse the existing task-parallel system of GHC to do the heavily lifting

[Haskell-cafe] Re[4]: Parallel combinator, performance advice

2009-04-07 Thread Bulat Ziganshin
Hello Neil, Tuesday, April 7, 2009, 7:33:25 PM, you wrote: parallel_ (x1:xs) = do sem - newQSem $ 1 - length xs forM_ xs $ \x - writeChan queue (x signalQSem sem, False) x1 addWorker waitQSem sem writeChan queue (signalQSem sem, True) waitQSem sem

[Haskell-cafe] Re[4]: Parallel combinator, performance advice

2009-04-07 Thread Bulat Ziganshin
Hello Neil, Tuesday, April 7, 2009, 7:47:17 PM, you wrote: para = mapM_ forkIO I might try that tomorrow and see if it makes a difference to the performance. While the majority of computation is in system calls, quite a few of the threads open files etc, and having them all run in parallel

Re: [Haskell-cafe] threadDelay granularity

2009-04-07 Thread Duane Johnson
The Hipmunk 2D physics engine comes with a playground app which includes the following function: -- | Advances the time. advanceTime :: IORef State - Double - KeyButtonState - IO Double advanceTime stateVar oldTime slowKey = do newTime - get time -- Advance simulation let slower = if

[Haskell-cafe] Re[5]: Parallel combinator, performance advice

2009-04-07 Thread Bulat Ziganshin
Hello Bulat, Tuesday, April 7, 2009, 7:50:08 PM, you wrote: parallel_ (x1:xs) = do sem - newQSem $ 1 - length xs forM_ xs $ \x - writeChan queue (x signalQSem sem, False) x1 addWorker waitQSem sem writeChan queue (signalQSem sem, True) waitQSem sem

[Haskell-cafe] Re: Re[5]: Parallel combinator, performance advice

2009-04-07 Thread Neil Mitchell
Hi par is likely to spark all the computations, and then switch between them - which will mean I've got more than N things running in parallel. | par/GHC RTS limits amount of Haskell threads running simultaneously. | with a system call marked as safe, Capability will be freed while we |

Re: [Haskell-cafe] threadDelay granularity

2009-04-07 Thread Peter Verswyvelen
yes get time comes from GLFW; that is get comes from OpenGL, time from GLFW. I think the time provided by GLFW has a very high resolution but is not very accurate in the long run, which is not a real problem for games I guess On Tue, Apr 7, 2009 at 6:09 PM, Duane Johnson

[Haskell-cafe] Re[6]: Parallel combinator, performance advice

2009-04-07 Thread Bulat Ziganshin
Hello Bulat, Tuesday, April 7, 2009, 8:10:43 PM, you wrote: parallel_ (x1:xs) = do sem - newQSem $ 1 - length xs forM_ xs $ \x - writeChan queue (x signalQSem sem, False) x1 addWorker waitQSem sem writeChan queue (signalQSem sem, True) waitQSem sem

Re: [Haskell-cafe] Re: Configuring cabal dependencies at install-time

2009-04-07 Thread John Dorsey
Edward, Thanks for straightening me out; I see the problems better now. In particular I was missing: 1) Orphaned types (and related design issues) get in the way of splitting the package. 2) Viral dependencies work in two directions, since upstream packages must pick up your deps to

[Haskell-cafe] Re: Configuring cabal dependencies at install-time

2009-04-07 Thread Simon Michael
I'm facing this problem too, with hledger. It has optional happstack and vty interfaces which add to the difficulty and platform-specificity of installation. Currently I publish all in one package with a cabal flag for each interface, with happstack off and vty on by default. vty isn't

Re: [Haskell-cafe] Monad transformer to consume a list

2009-04-07 Thread Stephan Friedrichs
My solution is this transformer: newtype ConsumerT c m a = ConsumerT { runConsumerT :: [c] - m (a, [c]) } instance (Monad m) = Monad (ConsumerT c m) where return x = ConsumerT $ \cs - return (x, cs) m = f = ConsumerT $ \cs - do ~(x, cs') - runConsumerT m cs

Re: [Haskell-cafe] Monad transformer to consume a list

2009-04-07 Thread Henning Thielemann
On Tue, 7 Apr 2009, Stephan Friedrichs wrote: My solution is this transformer: newtype ConsumerT c m a = ConsumerT { runConsumerT :: [c] - m (a, [c]) } instance (Monad m) = Monad (ConsumerT c m) where return x = ConsumerT $ \cs - return (x, cs) m = f = ConsumerT $ \cs - do

Re: [Haskell-cafe] Re: Configuring cabal dependencies at install-time

2009-04-07 Thread John Lato
The problem of type class instances for third-party types is exactly how I ran into this. Currently I don't know of a good solution, where good means that it meets these criteria: 1. Does not introduce orphan instances 2. Allows for instances to be provided based upon the user's installed

Re: [Haskell-cafe] How to cut a file effciently?

2009-04-07 Thread Luke Palmer
split n [] = [] split n xs = take n xs : split n (drop n xs) main = do text - readFile source mapM_ (\(n,dat) - writeFile (dest ++ show n) dat) . zip [0..] . split 1 . lines $ text Modulo brainos... but you get the idea. This is lazy (because readFile is). Luke On Tue, Apr 7, 2009