Re: [Haskell-cafe] Code walking off the right edge of the screen

2009-06-25 Thread Stephan Friedrichs
Henning Thielemann wrote: [...] http://haskell.org/haskellwiki/Case Maybe we (i. e. someone with a wiki account ;) ) should add Jeremy's proposal - using let and guards - to the page (under section 2.2, syntactic suger)? IMHO this is much clearer than case () of _. foo = let x | 1 1

Re: [Haskell-cafe] Using unsafePerformIO safely

2009-06-25 Thread Luke Palmer
On Wed, Jun 24, 2009 at 11:13 PM, Hector Guilarte hector...@gmail.comwrote: Thanks! Actually, if I understood well what you proposed, that's how I first tought of doing it, but with a [Maybe String] and only append whenever I actually had a (Just string), but as I said before, I don't think

Re: [Haskell-cafe] Using unsafePerformIO safely

2009-06-25 Thread minh thu
2009/6/25 Hector Guilarte hector...@gmail.com: On Fri, Jun 26, 2009 at 12:58 AM, Brandon S. Allbery KF8NH allb...@ece.cmu.edu wrote: On Jun 26, 2009, at 00:43 , Hector Guilarte wrote: Thanks! Actually, if I understood well what you proposed, that's how I first tought of doing it, but

Re: [Haskell-cafe] Using unsafePerformIO safely

2009-06-25 Thread Brandon S. Allbery KF8NH
On Jun 26, 2009, at 01:11 , Hector Guilarte wrote: Ok, I got it this time, thanks! I should really talk this with my teacher. I'll post whatever he tells me... Let's hope he lets me just acumulate all the strings and print them in the end. You're still missing what lazy evaluation means.

Re: [Haskell-cafe] Error in array index.

2009-06-25 Thread Claus Reinke
It's too bad that indexes are `Int` instead of `Word` under the hood. Why is `Int` used in so many places where it is semantically wrong? Not just here but also in list indexing... Indices/offsets can only be positive and I can't see any good reason to waste half the address space -- yet we

Re[2]: [Haskell-cafe] Error in array index.

2009-06-25 Thread Bulat Ziganshin
Hello Claus, Thursday, June 25, 2009, 11:50:12 AM, you wrote: PS. You could, of course, rebase your array indices to make use of the negatives, so the address space isn't wasted, just made difficult to use. no, he can't - internally indexes are always counted from 0, so array cannot

Re: [Haskell-cafe] Using unsafePerformIO safely

2009-06-25 Thread Ketil Malde
Luke Palmer lrpal...@gmail.com writes: mult2 x = unsafePerformIO $ do { print x; return (2*x) } main = do let answer = mult2 21 print answer print answer [this] would print 21,42,42. Thus our *correct* transformation of programs changed behavior. Just to expand a bit on

Re: [Haskell-cafe] Code walking off the right edge of the screen

2009-06-25 Thread Alberto G. Corona
What about extending haskell (or ghc) with mixfix operators, Agda style?. At first sigth it would permit the creation of custom control structures and perhaps more readable DSLs. 2009/6/25 Stephan Friedrichs deduktionstheo...@web.de Henning Thielemann wrote: [...]

[Haskell-cafe] How to fork a process?

2009-06-25 Thread Magicloud Magiclouds
Hi, In many language, both thread and process are supported. But in haskell's document, the only thing I could find called fork is to make a thread. So how to fork the program itself, like fork () in C? Thanks. -- 竹密岂妨流水过 山高哪阻野云飞 ___ Haskell-Cafe

Re: [Haskell-cafe] How to fork a process?

2009-06-25 Thread Brandon S. Allbery KF8NH
On Jun 25, 2009, at 05:01 , Magicloud Magiclouds wrote: In many language, both thread and process are supported. But in haskell's document, the only thing I could find called fork is to make a thread. So how to fork the program itself, like fork () in C? Internal threads can be done

[Haskell-cafe] combining monads with IO

2009-06-25 Thread Richard Silverman
Hi all, I'm puzzled by something. Suppose I have some code that does lots of IO, and also occasionally refers to some global state. No problem, use ReaderT for the state, combining with the IO monad. Except... since IO is on the bottom, simple uses of do-notation such as foo - ask work in

Re: [Haskell-cafe] combining monads with IO

2009-06-25 Thread Martijn van Steenbergen
Richard Silverman wrote: I'm puzzled by something. Suppose I have some code that does lots of IO, and also occasionally refers to some global state. No problem, use ReaderT for the state, combining with the IO monad. Except... since IO is on the bottom, simple uses of do-notation such as foo -

Re: [Haskell-cafe] combining monads with IO

2009-06-25 Thread Matthias Görgens
By the way, how would one write the following with Monad Transformers? newtype IOMayfail a = IOMayfail (IO (Maybe a)) instance Monad IOMayfail where return = IOMayfail . return . return (=) a f = IOMayfail (bind (run a) (run . f)) fail s = trace s (IOMayfail $ return Nothing)

Re: [Haskell-cafe] combining monads with IO

2009-06-25 Thread Miguel Mitrofanov
Well, without fail part: newtype IOMayfail a = IOMayfail (MaybeT IO a) deriving Monad Matthias Görgens wrote on 25.06.2009 17:14: By the way, how would one write the following with Monad Transformers? newtype IOMayfail a = IOMayfail (IO (Maybe a)) instance Monad IOMayfail where return

Re: [Haskell-cafe] combining monads with IO

2009-06-25 Thread Matthias Görgens
Thanks. Can I add something like fail? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

[Haskell-cafe] Another question about unsafePerformIO

2009-06-25 Thread Matthias Görgens
I have a program that optimizes train schedules. It employs an external solver for Integer Linear Programs. The solve function has the following type: solve :: Constraints - IO (Maybe Solution) And this works. However, my external solver also behaves like a pure function from input to

Re: [Haskell-cafe] Another question about unsafePerformIO

2009-06-25 Thread Jochem Berndsen
Matthias Görgens wrote: I have a program that optimizes train schedules. It employs an external solver for Integer Linear Programs. The solve function has the following type: solve :: Constraints - IO (Maybe Solution) And this works. However, my external solver also behaves like a pure

Re: [Haskell-cafe] combining monads with IO

2009-06-25 Thread Miguel Mitrofanov
Sure: newtype IOMayfail a = IOMayfail {runIOMayfail :: MaybeT IO a} instance Monad IOMayfail where return = IOMayfail . return IOMayfail m = f = IOMayfail $ m = runIOMayfail . f fail = whatever you like Matthias Görgens wrote on 25.06.2009 17:28: Thanks. Can I add something like fail?

Re: [Haskell-cafe] Another question about unsafePerformIO

2009-06-25 Thread John Meacham
On Thu, Jun 25, 2009 at 03:38:41PM +0200, Matthias Görgens wrote: I have a program that optimizes train schedules. It employs an external solver for Integer Linear Programs. The solve function has the following type: solve :: Constraints - IO (Maybe Solution) And this works. However,

Re: [Haskell-cafe] Another question about unsafePerformIO

2009-06-25 Thread Max Rabkin
On Thu, Jun 25, 2009 at 3:49 PM, John Meachamj...@repetae.net wrote: However, if the algorithm takes a signifigant amount of time or resources, you may want to keep it in IO just so users can have control over exactly when and how often it is run. If you had a pure function written in Haskell

Re: [Haskell-cafe] Another question about unsafePerformIO

2009-06-25 Thread Matthias Görgens
Adding 'unsafePerformIO' will work, but a better idea might be to understand why your solver has IO in its type signature. Is this because of FFI calls? You can remove IO in FFI calls if they are free from side effects as well. My solver has IO in the type signature, because I said so. :o)

[Haskell-cafe] Can you determine a constructor's arity using Data.Typeable and Data.Data?

2009-06-25 Thread David Fox
Is it possible to determine the arity of a value's constructor? Suppose I have a value x of type data A = B Int | C They typeOf function returns its TypeRep, which contains its type constructor, but I don't see how to decide whether that constructor's arity is 0 or 1. If the type has field

[Haskell-cafe] Hack (web) and apache configuration

2009-06-25 Thread Henry Laxen
Dear Group, I am posting this here even though it probably belongs on the apache list because I suspect other haskell users will be able to find it here more easily. I am playing around with hack, and am having trouble with configuring apache with fastcgi to make things work. My understanding

[Haskell-cafe] Using unsafePerformIO safely

2009-06-25 Thread gladstein
Regarding how to make the show instructions cause printout as soon as they are executed: If you write your interpreter to return a list of printout lines (strings), you get this behavior for free. Haskell's laziness enables the printing to start right away, while in an imperative language the

Re: [Haskell-cafe] Can you determine a constructor's arity using Data.Typeable and Data.Data?

2009-06-25 Thread José Pedro Magalhães
Hey David, For instance: arity :: (Data a) = a - Int arity = length . gmapQ (const ()) Cheers, Pedro On Thu, Jun 25, 2009 at 17:31, David Fox dds...@gmail.com wrote: Is it possible to determine the arity of a value's constructor? Suppose I have a value x of type data A = B Int | C

Re: [Haskell-cafe] [ANN] full-sessions: yet another implementation of session types

2009-06-25 Thread Jason Dusek
Is there a relationship between sessions and coroutines? -- Jason Dusek ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] GHCi infers a type but refuses it as type signature

2009-06-25 Thread Wei Hu
Could you or anyone else briefly explain how mmtl solves the combinatorical explosion problem? Reading the source code is not very productive for newbies like me. Thanks! On Tue, Jun 23, 2009 at 5:34 AM, Luke Palmerlrpal...@gmail.com wrote: On Tue, Jun 23, 2009 at 2:20 AM, papa.e...@free.fr

Re: [Haskell-cafe] GHCi infers a type but refuses it as type signature

2009-06-25 Thread Wei Hu
OK, I found two papers by the author, Mauro Jaskelioff, that seem relevant. One paper Modular Monad Transformers is all category theoretical. Maybe I should read the other one Monatron: An Extensible Monad Transformer Library. On Thu, Jun 25, 2009 at 12:17 PM, Wei Huwei@gmail.com wrote:

Re: [Haskell-cafe] Hack (web) and apache configuration

2009-06-25 Thread Anton van Straaten
Henry Laxen wrote: I have tried several things, the most recent being: RewriteEngine on RewriteRule ^/(.*)$ /hackTest?input=$1 [T=application/x-httpd-cgi] Location / SetHandler fastcgi-script Options ExecCGI FollowSymLinks /Location but the pathInfo field is always null. Path info

Re: [Haskell-cafe] GHCi infers a type but refuses it as type signature

2009-06-25 Thread David Menendez
On Thu, Jun 25, 2009 at 12:17 PM, Wei Huwei@gmail.com wrote: Could you or anyone else briefly explain how mmtl solves the combinatorical explosion problem? Reading the source code is not very productive for newbies like me. Thanks! It's a good question, since from what I can tell mmtl does

Re: [Haskell-cafe] Can you determine a constructor's arity using Data.Typeable and Data.Data?

2009-06-25 Thread David Fox
Oh, that make sense! 2009/6/25 José Pedro Magalhães j...@cs.uu.nl Hey David, For instance: arity :: (Data a) = a - Int arity = length . gmapQ (const ()) Cheers, Pedro On Thu, Jun 25, 2009 at 17:31, David Fox dds...@gmail.com wrote: Is it possible to determine the arity of a

[Haskell-cafe] Re: Hack (web) and apache configuration

2009-06-25 Thread Henry Laxen
Anton van Straaten anton at appsolutions.com writes: Path info is path-like data that directly follows the name of the resource being referenced, e.g.: /myfiles/foo.html/this/is/path/info A rule that would give you path info in the case you describe would be more like this:

Re: [Haskell-cafe] Parsing .dot files?

2009-06-25 Thread Neil Mitchell
Hi I have some code, but never got round to uploading it or turning it in to a package. If the graphviz package doesn't have what you want I'm happy to give you a copy. (I would attach the code but I don't have it on this machine) Thanks Neil On Wed, Jun 24, 2009 at 7:38 AM, minh

[Haskell-cafe] Re: Hack (web) and apache configuration

2009-06-25 Thread Simon Michael
harack ? *Harack*. Excuse me. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] Haskell on JVM

2009-06-25 Thread Jason Dusek
2009/06/24 Greg Meredith lgreg.mered...@biosimilarity.com: Better support for std Haskell syntax What does this mean, actually? Better support for standard Haskell syntax than what? -- Jason Dusek ___ Haskell-Cafe mailing list

Re: [Haskell-cafe] unique identity and name shadowing during type inference

2009-06-25 Thread Geoffrey Irving
Thanks. I'll go with the monad for now. Geoffrey On Sat, Jun 20, 2009 at 4:40 PM, Lennart Augustssonlenn...@augustsson.net wrote: Use 1. You'll probably need a monad in the type checker soon or later anyway, e.g., for handling errors. On Sun, Jun 21, 2009 at 5:13 AM, Zsolt

Re: [Haskell-cafe] Haskell on JVM

2009-06-25 Thread Greg Meredith
Jason, CAL's syntax is not std Haskell syntax. Best wishes, --greg On Thu, Jun 25, 2009 at 11:10 AM, Jason Dusek jason.du...@gmail.com wrote: 2009/06/24 Greg Meredith lgreg.mered...@biosimilarity.com: Better support for std Haskell syntax What does this mean, actually? Better support

Re: [Haskell-cafe] [ANN] full-sessions: yet another implementation of session types

2009-06-25 Thread Jason Dusek
Having read some of the material, it seems that sessions are far richer than would be needed for most coroutines. -- Jason Dusek ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] GHCi infers a type but refuses it as type signature

2009-06-25 Thread Wei Hu
On Thu, Jun 25, 2009 at 1:10 PM, David Menendezd...@zednenem.com wrote: On Thu, Jun 25, 2009 at 12:17 PM, Wei Huwei@gmail.com wrote: Could you or anyone else briefly explain how mmtl solves the combinatorical explosion problem? Reading the source code is not very productive for newbies

Re: [Haskell-cafe] GHCi infers a type but refuses it as type signature

2009-06-25 Thread wren ng thornton
Bulat Ziganshin wrote: Hello wren, Thursday, June 25, 2009, 6:35:36 AM, you wrote: Rank2Types, RankNTypes, ExistentialQuantification, ScopedTypeVariables, and GADTs are fairly benign ---though this is where you start loosing compatibility with non-GHC compilers. afair, except for GADTs

Re: [Haskell-cafe] combining monads with IO

2009-06-25 Thread wren ng thornton
Richard Silverman wrote: Hi all, I'm puzzled by something. Suppose I have some code that does lots of IO, and also occasionally refers to some global state. No problem, use ReaderT for the state, combining with the IO monad. Except... since IO is on the bottom, simple uses of do-notation

Re: [Haskell-cafe] Generic Graph Class

2009-06-25 Thread Ivan Lazar Miljenovic
Some of us on #haskell last night (well, night for me :p) were discussing this, and we're going to start a new project to implement an extended version of my proposal. The working project name is simply graph (hey, we couldn't think of anything better!). If you want to join in the fun, talk to