Re: [Haskell-cafe] (weird stuff) Kernel Modules in Haskell ;-)

2009-09-15 Thread minh thu
2009/9/15 Matthias Kilian : > A fellow openbsd developer told me the URL below... > > I hope this hasn't been posted on this list already (at least I > didn't find it in my local archives): > > http://tommd.wordpress.com/2009/09/13/kernel-modules-in-haskell/ I don't think it was posted here, but i

[Haskell-cafe] A thought about liberating Haskell's syntax

2009-09-15 Thread George Pollard
Dear all, Here is a note concerning a thought I just had. I have written a rough sketch/outline and would like feedback upon this. The beginning thought: I would like to be able to write new bracket-like operators without having to rewrite GHC. (Case in point: applicative brackets.) First idea i

Re: [Haskell-cafe] adding state in GUIs (qtHaskell)

2009-09-15 Thread Alp Mestan
On Fri, Sep 11, 2009 at 5:55 PM, Jeremy O'Donoghue < jeremy.odonog...@gmail.com> wrote: > > > I don't have anything as neat to show you as Duncan's suggetion (I'd also > be interested to see a cleaner way to do it - this sort of code always > grates a little with me, although all of the major Has

Re: [Haskell-cafe] Building a monoid, continuation-passing style

2009-09-15 Thread Derek Elkins
On Mon, Sep 14, 2009 at 10:25 AM, Martijn van Steenbergen wrote: > Hello cafe, > > Inspired by Sean Leather's xformat package [1] I built a datatype with which > you can build a monoid with holes, yielding a function type to fill in these > holes, continuation-passing style. Here are some primitiv

Re: [Haskell-cafe] Building a monoid, continuation-passing style

2009-09-15 Thread David Menendez
On Mon, Sep 14, 2009 at 11:25 AM, Martijn van Steenbergen wrote: > Inspired by Sean Leather's xformat package [1] I built a datatype with which > you can build a monoid with holes, yielding a function type to fill in these > holes, continuation-passing style. Neat! > I have a couple of questions

Re: [Haskell-cafe] algebra/grammar/language for expressing time intervals

2009-09-15 Thread Iain Alexander
You might want to take a look at RFC 2445 Internet Calendaring and Scheduling Core Object Specification Section 4.8.5.4 Recurrence Rule -- Iain Alexander i...@stryx.demon.co.uk ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haske

[Haskell-cafe] loading object code with ghci

2009-09-15 Thread Ryan Wisnesky
Hello, I'm having some trouble correctly linking to externally generated object code when using ghci. I'm loading a Cabal package Foo, that has already been successfully installed: >ghci -package Foo ghc-6.8.3: unknown symbol `_iceExePath' Loading package Foo-0.1 ... linking ... ghc-6.8.3:

Re: [Haskell-cafe] What does it mean that objects are fixpoints? (OO'Haskell)

2009-09-15 Thread Derek Elkins
On Tue, Sep 15, 2009 at 10:14 AM, Manuel Simoni wrote: > Hello! > > I'm trying to wrap my head around OO'Haskell's notion of objects as fixpoints. > > Is OO'Haskell's use of mfix simply a use of something like a monadic > Y-combinator to give the object access to its own "identity"? More or less,

Re: [Haskell-cafe] Do I have this right? "Remembering" Memoization!

2009-09-15 Thread Derek Elkins
> But pedantically even the function: > >> quux :: Int -> Int >> quux x = trace "Quux" (bar 12) > >> optmain :: IO () >> optmain = quux 10 `seq` quux 11 `seq` return () > > might print only once if GHC at the optimization level selected recognizes > that quux doesn't depend on its argument and rewr

Re: [Haskell-cafe] How to understand the 'forall' ?

2009-09-15 Thread Daniel Fischer
Am Dienstag 15 September 2009 23:13:59 schrieb Cristiano Paris: > On Wed, Sep 2, 2009 at 7:16 AM, zaxis wrote: > > Isnot it clear without the 'forall' ? > > data Branch tok st a = Branch (PermParser tok st (b -> a)) (GenParser tok > > st b) > > > > thanks! > > I elaborated on this and I wish to ad

Re: [Haskell-cafe] Parallel graphics

2009-09-15 Thread namekuseijin
On Tue, Sep 15, 2009 at 8:48 AM, Andrew Coppin wrote: > Using explicit threads has the nice side-effect... side-effects are bad! ;-) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] Is it safe to use unsafePerformIO here?

2009-09-15 Thread Daniel Fischer
Am Dienstag 15 September 2009 23:00:40 schrieb Cristiano Paris: > On Tue, Sep 15, 2009 at 10:42 PM, Daniel Fischer > > wrote: > > > > Aaawww. > > let b' = length b > > or > > let b' = foldl' seq () b > > or > > let b' = b `using` rnf > > > > if you want to force the whole file to be read. But

Re: [Haskell-cafe] How to understand the 'forall' ?

2009-09-15 Thread Cristiano Paris
On Wed, Sep 2, 2009 at 7:16 AM, zaxis wrote: > > Isnot it clear without the 'forall' ? > data Branch tok st a = Branch (PermParser tok st (b -> a)) (GenParser tok st > b) > > thanks! I elaborated on this and I wish to add my personal way of figuring out what the "forall" keyword means. When you

Re: [Haskell-cafe] Announce: EnumMap-0.0.1

2009-09-15 Thread Felipe Lessa
On Mon, Sep 14, 2009 at 11:32:04PM -0400, John Van Enk wrote: > http://hackage.haskell.org/package/EnumMap > > Changes pushed. Job Vranish added the SPECIALIZE pragmas, and I believe he > has more data concerning how much this helps. Thanks a lot! :) -- Felipe. ___

Re: [Haskell-cafe] Is it safe to use unsafePerformIO here?

2009-09-15 Thread Cristiano Paris
On Tue, Sep 15, 2009 at 10:42 PM, Daniel Fischer wrote: > > Aaawww. > let b' = length b > or > let b' = foldl' seq () b > or > let b' = b `using` rnf > > if you want to force the whole file to be read. But then you should > definitely be using > ByteStrings. Yep. But that doesn't solve the

Re: [Haskell-cafe] Is it safe to use unsafePerformIO here?

2009-09-15 Thread Daniel Fischer
Am Dienstag 15 September 2009 22:25:31 schrieb Cristiano Paris: > On Tue, Sep 15, 2009 at 10:11 PM, Cristiano Paris wrote: > > On Tue, Sep 15, 2009 at 10:08 PM, Cristiano Paris > > wrote: > >> ... > >> So, it seems that "seq b" is completely ineffective and program is not > >> correct. > > > > C

Re: [Haskell-cafe] Is it safe to use unsafePerformIO here?

2009-09-15 Thread Cristiano Paris
On Tue, Sep 15, 2009 at 10:29 PM, Daniel Fischer wrote: > ... > It evaluates the String far enough to know whether it's "" or (_:_), that is, > to weak head > normal form. It doesn't look at any character, but it forces at least one > character to be > read from the file. Yep, the head. That ex

[Haskell-cafe] (weird stuff) Kernel Modules in Haskell ;-)

2009-09-15 Thread Matthias Kilian
A fellow openbsd developer told me the URL below... I hope this hasn't been posted on this list already (at least I didn't find it in my local archives): http://tommd.wordpress.com/2009/09/13/kernel-modules-in-haskell/ Ciao, Kili -- Logging should be in debug mode only. If every netw

Re: [Haskell-cafe] Is it safe to use unsafePerformIO here?

2009-09-15 Thread Cristiano Paris
On Tue, Sep 15, 2009 at 10:08 PM, Cristiano Paris wrote: > ... > So, it seems that "seq b" is completely ineffective and program is not > correct. Correction: removing "seq b" results in nothing being displayed :) So, it's not "completely" effective. I suspect this is related to the fact that a

Re: [Haskell-cafe] Is it safe to use unsafePerformIO here?

2009-09-15 Thread Cristiano Paris
On Tue, Sep 15, 2009 at 9:29 PM, Daniel Fischer wrote: > Am Dienstag 15 September 2009 21:13:02 schrieb Daniel Fischer: >> Still, the body should be read lazily. >> I'm not sure, but the tracing message may be output because of its >> position. >> >> With >> >> where >>     readBody = withFile fn

Re: [Haskell-cafe] Is it safe to use unsafePerformIO here?

2009-09-15 Thread Daniel Fischer
Am Dienstag 15 September 2009 22:17:00 schrieb Cristiano Paris: > On Tue, Sep 15, 2009 at 10:12 PM, Ross Mellgren wrote: > > Wouldn't seq b only force (at minimum) the first character of the file? > > I think it force the evaluation of the "Cons" in the String but not > the characters therein. It

Re: [Haskell-cafe] Is it safe to use unsafePerformIO here?

2009-09-15 Thread Cristiano Paris
On Tue, Sep 15, 2009 at 10:25 PM, Cristiano Paris wrote: > ... > Two points: > > 1 - I had to cut off file1.txt to be just above 1024 bytes otherwise > the program becomes extremely slow even on a 100KB file with a line > being output every 5 seconds and with my CPU being completely busy > (I'm us

Re: [Haskell-cafe] Is it safe to use unsafePerformIO here?

2009-09-15 Thread Cristiano Paris
On Tue, Sep 15, 2009 at 10:20 PM, Ross Mellgren wrote: > Ack, IGNORE ME! Way too strict. Oh, well, I used foldr+seq to achieve the same result... I think, but I think that, if this is the solution, I'll use rnf as I did on other occasions. Thanks. Cristiano _

Re: [Haskell-cafe] Is it safe to use unsafePerformIO here?

2009-09-15 Thread Cristiano Paris
On Tue, Sep 15, 2009 at 10:11 PM, Cristiano Paris wrote: > On Tue, Sep 15, 2009 at 10:08 PM, Cristiano Paris wrote: >> ... >> So, it seems that "seq b" is completely ineffective and program is not >> correct. > > Correction: removing "seq b" results in nothing being displayed :) > > So, it's not

Re: [Haskell-cafe] Parallel graphics

2009-09-15 Thread Edward Kmett
Block, line or 'beam' decomposition tends to work well for raytracing tasks, because they tend to give you a good cache locality and don't create a ridiculous explosion of parallel jobs. You'll need to do some tuning to figure out the right granularity for the decomposition. But typically a few hu

Re: [Haskell-cafe] Is it safe to use unsafePerformIO here?

2009-09-15 Thread Ross Mellgren
Ack, IGNORE ME! Way too strict. -Ross On Sep 15, 2009, at 4:20 PM, Ross Mellgren wrote: Ah yeah, that too. Control.Parallel.Strategies.rnf to the rescue? -Ross On Sep 15, 2009, at 4:17 PM, Cristiano Paris wrote: On Tue, Sep 15, 2009 at 10:12 PM, Ross Mellgren hask...@z.odi.ac> wrote: Wouldn

Re: [Haskell-cafe] Is it safe to use unsafePerformIO here?

2009-09-15 Thread Ross Mellgren
Ah yeah, that too. Control.Parallel.Strategies.rnf to the rescue? -Ross On Sep 15, 2009, at 4:17 PM, Cristiano Paris wrote: On Tue, Sep 15, 2009 at 10:12 PM, Ross Mellgren hask...@z.odi.ac> wrote: Wouldn't seq b only force (at minimum) the first character of the file? I think it force the e

Re: [Haskell-cafe] Is it safe to use unsafePerformIO here?

2009-09-15 Thread Cristiano Paris
On Tue, Sep 15, 2009 at 10:12 PM, Ross Mellgren wrote: > Wouldn't seq b only force (at minimum) the first character of the file? I think it force the evaluation of the "Cons" in the String but not the characters therein. Cristiano ___ Haskell-Cafe mail

Re: [Haskell-cafe] Is it safe to use unsafePerformIO here?

2009-09-15 Thread Ross Mellgren
Wouldn't seq b only force (at minimum) the first character of the file? -Ross On Sep 15, 2009, at 4:08 PM, Cristiano Paris wrote: On Tue, Sep 15, 2009 at 9:29 PM, Daniel Fischer wrote: Am Dienstag 15 September 2009 21:13:02 schrieb Daniel Fischer: Still, the body should be read lazily. I'm

Re: [Haskell-cafe] Do I have this right? "Remembering" Memoization!

2009-09-15 Thread Edward Kmett
I agree with what you meant, but not quite with what you said. To be pedantic: > import Debug.Trace > foo :: Int > foo = trace "Foo" (bar 12) > bar :: Int -> Int > bar x = trace "Bar" x > main :: IO () > main = foo `seq` foo `seq` return () main prints "Foo\nBar\n" showing that the bar is only

Re: [Haskell-cafe] Is it safe to use unsafePerformIO here?

2009-09-15 Thread Cristiano Paris
On Tue, Sep 15, 2009 at 9:39 PM, Svein Ove Aas wrote: > As a general sort of warning, do not use hGetContents (or lazy i/o, in > general) in combination with withFile. > > withFile closes the handle when the program lexically exits its scope. > However, when using hGetContents, the file contents w

Re: [Haskell-cafe] Is it safe to use unsafePerformIO here?

2009-09-15 Thread Svein Ove Aas
As a general sort of warning, do not use hGetContents (or lazy i/o, in general) in combination with withFile. withFile closes the handle when the program lexically exits its scope. However, when using hGetContents, the file contents will not be read until after you do this, and will therefore fail

Re: [Haskell-cafe] Is it safe to use unsafePerformIO here?

2009-09-15 Thread Cristiano Paris
On Tue, Sep 15, 2009 at 9:16 PM, Svein Ove Aas wrote: > I have a number of suggestions, some of which conflict with each > other, so I'll just throw them out here. Let's see.. :) > First off, the IO monad does indeed enforce sequencing; that's its > primary purpose. So, unsafePerformIO can be t

Re: [Haskell-cafe] Is it safe to use unsafePerformIO here?

2009-09-15 Thread Daniel Fischer
Am Dienstag 15 September 2009 21:13:02 schrieb Daniel Fischer: > Still, the body should be read lazily. > I'm not sure, but the tracing message may be output because of its > position. > > With > > where >     readBody = withFile fn ReadMode $ \h -> do >         b <- hGetContents h >         seq b

Re: [Haskell-cafe] Is it safe to use unsafePerformIO here?

2009-09-15 Thread Cristiano Paris
On Tue, Sep 15, 2009 at 9:13 PM, Daniel Fischer wrote: > ... > Still, the body should be read lazily. > I'm not sure, but the tracing message may be output because of its position. > > With > > where >    readBody = withFile fn ReadMode $ \h -> do >        b <- hGetContents h >        seq b $ retu

Re: [Haskell-cafe] Is it safe to use unsafePerformIO here?

2009-09-15 Thread Svein Ove Aas
I have a number of suggestions, some of which conflict with each other, so I'll just throw them out here. Let's see.. First off, the IO monad does indeed enforce sequencing; that's its primary purpose. However, you can ask for it to run I/O out of order, specifically when the value the out-of-orde

Re: [Haskell-cafe] Is it safe to use unsafePerformIO here?

2009-09-15 Thread Daniel Fischer
Am Dienstag 15 September 2009 20:36:06 schrieb Cristiano Paris: > Hi Cafè, > > I've the following problem: I have a (possibly very long) list of > files on disk. Each file contains some metadata at the beginning and > continues with a (possibly very large) chunk of data. > > Now, the program I'm wr

[Haskell-cafe] Is it safe to use unsafePerformIO here?

2009-09-15 Thread Cristiano Paris
Hi Cafè, I've the following problem: I have a (possibly very long) list of files on disk. Each file contains some metadata at the beginning and continues with a (possibly very large) chunk of data. Now, the program I'm writing can be run in two modes: either read a specific file from the disk and

Re: [Haskell-cafe] Typeclasses vs simple functions?

2009-09-15 Thread Olex P
Thanks for explanation Sean! On Tue, Sep 15, 2009 at 4:30 PM, Sean Leather wrote: > > >> "Existential types" sounds a bit scary :) >> >>> > It's unfortunate that they've developed a scariness feeling associated with > them. They can be used in strange ways, but simple uses are quite > approachab

Re: [Haskell-cafe] What does it mean that objects are fixpoints? (OO'Haskell)

2009-09-15 Thread Sean Leather
> I'm trying to wrap my head around OO'Haskell's notion of objects as > fixpoints. > > Is OO'Haskell's use of mfix simply a use of something like a monadic > Y-combinator to give the object access to its own "identity"? > I don't remember the details exactly, but isn't it to support open recursion

Re: [Haskell-cafe] Typeclasses vs simple functions?

2009-09-15 Thread Sean Leather
> "Existential types" sounds a bit scary :) > >> It's unfortunate that they've developed a scariness feeling associated with them. They can be used in strange ways, but simple uses are quite approachable. One way to think of them is like implementing an object-oriented interface. You know it's an o

[Haskell-cafe] What does it mean that objects are fixpoints? (OO'Haskell)

2009-09-15 Thread Manuel Simoni
Hello! I'm trying to wrap my head around OO'Haskell's notion of objects as fixpoints. Is OO'Haskell's use of mfix simply a use of something like a monadic Y-combinator to give the object access to its own "identity"? Thanks, Manuel ___ Haskell-Cafe mai

Re: [Haskell-cafe] Typeclasses vs simple functions?

2009-09-15 Thread Olex P
It's hard to say what really is 2d or 3d. Think about closed 3d curve (points placed in 3d space somehow). Is it 2d or 3d? Depends on the interpretation. Usually DCC packages don't care about this. And I wouldn't too :p Who needs extra level of complexity without any reason? On Tue, Sep 15, 2009 a

Re: [Haskell-cafe] Typeclasses vs simple functions?

2009-09-15 Thread Tom Nielsen
I think you are in trouble because you have mixed 2D and 3D shapes in one data type. --not checked for typos, syntax, idiocy etc. {-# LANGUAGE GADTs #-} data Z data S n type Two = S (S Z) type Three = S Two data Geometry dims where Sphere :: Position -> Radius -> Geometry Three Cylinder

Re: [Haskell-cafe] Typeclasses vs simple functions?

2009-09-15 Thread Olex P
Cool. It's more and more clear guys. Thanks a lot. I'll check that "expression problem". "Existential types" sounds a bit scary :) On Tue, Sep 15, 2009 at 3:26 PM, Sean Leather wrote: > > >> Perimeter doesn't make sense for Sphere or Cylinder. So we could define a >> type class for objects that

Re: [Haskell-cafe] Typeclasses vs simple functions?

2009-09-15 Thread Sean Leather
> Perimeter doesn't make sense for Sphere or Cylinder. So we could define a > type class for objects that have perimeter and make an instance of it only > for Circle (data Circle = Circle Position Radius). Make sense. But these > three functions above have desired behaviour. If user has a list of o

Re: [Haskell-cafe] Typeclasses vs simple functions?

2009-09-15 Thread John Dorsey
> perimeter :: Geometry -> Double > perimeter (Sphere _ r) = 0.0 > perimeter (Circle _ r) = 2.0 * pi * r > > The latter is even simpler because there is no need in extraction of Double > value from Maybe. I'd strongly advise against this last one on style grounds. (0 :: Double) isn't nearly as s

[Haskell-cafe] Typeclasses vs simple functions?

2009-09-15 Thread Lyndon Maydwell
-- Forwarded message -- From: Lyndon Maydwell Date: Tue, Sep 15, 2009 at 10:03 PM Subject: Re: [Haskell-cafe] Typeclasses vs simple functions? To: Olex P I think it depends on what is going to be using the functions, data. As far as I can tell, type classes seem to be used in co

Re: [Haskell-cafe] Typeclasses vs simple functions?

2009-09-15 Thread Olex P
Well... How this: instance Encircled Geometry where perimeter (Sphere _ r) = Nothing perimeter (Circle _ r) = Just $ 2.0 * pi * r differs from this: perimeter :: Geometry -> Maybe Double perimeter (Sphere _ r) = Nothing perimeter (Circle _ r) = Just $ 2.0 * pi * r and from this:

Re: [Haskell-cafe] ANNOUNCE: LambdaINet-0.1.0, Graphical Interaction Net Evaluator for Optimal Evaluation

2009-09-15 Thread Paul L
Now it's at version 0.1.2 with the EnableGUI fix for Mac OS X. On 9/14/09, Paul L wrote: > I just bumped the version to 0.1.1 that fixes an embarrassing bug, > i.e., the first example shown on the screen was actually wrong. > > I took a screenshot of the interaction net showing (church 2) f x, >

Re: [Haskell-cafe] HDBC Oracle bindings(?/!)

2009-09-15 Thread Daniil Elovkov
Hello Thiago, John. I've taken the Oracle HDBC driver at http://thiagoarrais.com/repos/hdbc-oracle modified it just a little to suite 6.10.4 and briefly looked if it works. It does, that's cool! Thanks Thiago! A question follows, maybe it's worth to mention it at the HDBC page and/or put it

Re: Re[2]: [Haskell-cafe] Cabal install on Windows 7

2009-09-15 Thread Peter Verswyvelen
Yes, I'm aware of that, but not the details, so thanks for the info. Anyway, I quickly tested Regis's idea in C#, and it works as he said. http://hpaste.org/fastcgi/hpaste.fcgi/view?id=9392#a9392 - When trying to create a folder in ProgramFiles, you get an access denied exception, unless the prog

Re: [Haskell-cafe] Parallel graphics

2009-09-15 Thread minh thu
Hi Andrew, 2009/9/15 Andrew Coppin : > ... > I'm presuming that sparking every individual point is going to create > billions of absolutely tiny sparks, which probably won't give great > performance. We could spark every line rather than every point? > ... You should just try: no one can say if p

[Haskell-cafe] Parallel graphics

2009-09-15 Thread Andrew Coppin
I have a number of compute-bound graphics programs written in Haskell. (Fractal generators, ray tracers, that kind of thing.) GHC offers several concurrency and parallelism abstractions, but what's the best way to use these to get images rendered as fast as possible, using the available compute

Re: [Haskell-cafe] Typeclasses vs simple functions?

2009-09-15 Thread Olex P
Sure! I completely forgot about Maybe. The only one question is is it good from the point of view of ordinary user who doesn't know about such things like functional programming, monads etc. Imagine average user who is looking into a spreadsheet and sees values 0.1, 1.4, Nothing... From other side

[Haskell-cafe] Typeclasses vs simple functions?

2009-09-15 Thread Olex P
Hey guys, It's a dumb question but I'd like to know a right answer... Let's say we have some geometry data that can be Sphere, Cylinder, Circle and so on. We can implement it as new data type plus a bunch of functions that work on this data: data Geometry = Sphere Position Radius

Re[2]: [Haskell-cafe] Cabal install on Windows 7

2009-09-15 Thread Bulat Ziganshin
Hello Peter, Tuesday, September 15, 2009, 1:24:26 PM, you wrote: in order to protect from viruses and so now windows programs should be split into two parts - one that doesn't need admin privileges and one that needs them. as far as your actions doesn't need second part, you are running first pro

Re: [Haskell-cafe] Cabal install on Windows 7

2009-09-15 Thread Peter Verswyvelen
It is possible for an executable with less privileges to "shellexecute" an executable that requires admin rights? Won't this immediately raise an "access denied" or other security exception again? Don't know, it might be possible, but it's worth to check it out before going this route (which is rat

RE: [Haskell-cafe] Cabal install on Windows 7

2009-09-15 Thread Regis Saint-Paul
> > - use windows API for requesting elevation during the process (ugly) > > If it really has to be done, then this seems like the best approach. In > principle there's no problem with calling funky win32 functions in > Cabal, it's mostly a matter of working out what bahaviour we want and > what