Re: Re[Haskell-cafe] [2]: Threading and FFI

2010-02-20 Thread Dean Herington
At 2:53 PM -0800 2/18/10, Yves Parès wrote: Ben Franksen wrote: You can leave them unsafe if you are sure that 1) they do not call (back) any function in your program 2) they do not block (or not long enough that it bothers you) Otherwise they are no less safe that the safe calls. If (1) is

[Haskell-cafe] Re: Threading and FFI

2010-02-20 Thread Maciej Piechotka
Sorry I start spin-off of thread but all over the haskell code is idiom: throwErrorIfMinus1_ $ someCode args However this code is dependent on errno, which is thread dependent. Is GHC making sure that errno set from C call is propagated back into correct thread? Are there any requirements

[Haskell-cafe] Computing sums

2010-02-20 Thread Andrew Coppin
The other day, I found myself writing the following code: data Property x y = forall s. Property s (x - s - s) (s - y) step :: x - Property x y - Property x y step x (Property s f g) = Property (f x s) f g read :: Property x y - y read (Property s _ g) = g s pure :: (x - y) - Property x y

Re: [Haskell-cafe] Computing sums

2010-02-20 Thread Luke Palmer
On Sat, Feb 20, 2010 at 3:30 AM, Andrew Coppin andrewcop...@btinternet.com wrote: Have I just invented arrows? No... you have a data type which is *an* Arrow (probably/almost). The pure implementation bugs me because of its use of undefined. Might still be okay though. I would be more

[Haskell-cafe] A small oversight

2010-02-20 Thread Andrew Coppin
I just discovered the highly useful function Data.Function.on. I vaguely recall a few people muttering a couple of years back that this would be a useful thing to have, but I had no idea it was in the standard libraries now. Anyway, while using it, I discovered a small omission from the

Re: [Haskell-cafe] A small oversight

2010-02-20 Thread Holger Siegel
Am Samstag, den 20.02.2010, 10:47 + schrieb Andrew Coppin: I just discovered the highly useful function Data.Function.on. I vaguely recall a few people muttering a couple of years back that this would be a useful thing to have, but I had no idea it was in the standard libraries now.

Re: [Haskell-cafe] A small oversight

2010-02-20 Thread Matthias Görgens
Also, constructions like  sortBy (compare `on` foo) must surely be very common. Just as a data point: I use constructions like the above very often. (Perhaps someone more enlightened than me can point out the connection to arrows?) Data.Function.on is surprisingly useful in some other

Re: [Haskell-cafe] Computing sums

2010-02-20 Thread Andrew Coppin
Luke Palmer wrote: On Sat, Feb 20, 2010 at 3:30 AM, Andrew Coppin andrewcop...@btinternet.com wrote: Have I just invented arrows? No... you have a data type which is *an* Arrow (probably/almost). Well, OK, that's kind of what I meant. ;-) The pure implementation bugs me because of

Re: [Haskell-cafe] What happened in Ohloh?

2010-02-20 Thread Paul Johnson
On 19/02/10 22:31, Don Stewart wrote: paul: I'd like to use this kind of graph at work as evidence that Haskell is on a growth trajectory. You might be more interested in data from Hackage: http://www.galois.com/blog/2009/03/23/one-million-haskell-downloads/ runched when we

Re: [Haskell-cafe] Computing sums

2010-02-20 Thread Andrew Coppin
Anyway, for yours: try to implement (.) :: Property b c - Property a b - Property a c, and first :: Property a b - Property (a,c) (b,c). Then you will have an arrow. (.) = flip (==) first p = p == pure id No, not quite. \p - p == pure id :: Property a b - Property a (b, a) What you

Re: [Haskell-cafe] Computing sums

2010-02-20 Thread Stephen Tetley
Hi Andrew Spot the difference data Property x y = forall s. Property s (x - s - s) (s - y) data Fold b c = forall a. F (a - b - a) a (a - c) The later is from: http://squing.blogspot.com/2008/11/beautiful-folding.html Max Rabkin's is is closer to the original argument ordering of foldl. Best

Re: Re[Haskell-cafe] [2]: Threading and FFI

2010-02-20 Thread Yves Parès
Dean Herington wrote: Careful. If you're calling foreign functions that rely on thread-local storage, you must call them using the same OS thread (to provide them with the correct thread state), which means using the same, *bound*, Haskell thread. It wouldn't work to call them from both the

Re: [Haskell-cafe] Computing sums

2010-02-20 Thread Andrew Coppin
Stephen Tetley wrote: Hi Andrew Spot the difference data Property x y = forall s. Property s (x - s - s) (s - y) data Fold b c = forall a. F (a - b - a) a (a - c) The later is from: http://squing.blogspot.com/2008/11/beautiful-folding.html Max Rabkin's is is closer to the original argument

Re: [Haskell-cafe] Computing sums

2010-02-20 Thread Max Rabkin
On Sat, Feb 20, 2010 at 9:10 PM, Andrew Coppin andrewcop...@btinternet.com wrote: PS. Epic, epic comment spam. Yeah, sorry. Every now and again I decide I should deal with it. Then I rediscover that it takes about four clicks to delete each comment. Basically, I leave my blog alone until I have

Re: [Haskell-cafe] A small oversight

2010-02-20 Thread Ben Millwood
I can't answer your question (about getting minBy into the libraries) but I thought I'd point out some tricks: On Sat, Feb 20, 2010 at 10:47 AM, Andrew Coppin andrewcop...@btinternet.com wrote: Also, constructions like  sortBy (compare `on` foo) must surely be very common. Common enough

Re: [Haskell-cafe] A small oversight

2010-02-20 Thread Andrew Coppin
Ben Millwood wrote: I can't answer your question (about getting minBy into the libraries) but I thought I'd point out some tricks: On Sat, Feb 20, 2010 at 10:47 AM, Andrew Coppin andrewcop...@btinternet.com wrote: Also, constructions like sortBy (compare `on` foo) must surely be very

[Haskell-cafe] Re: darcs 2.4 release candidate 2

2010-02-20 Thread Petr Rockai
Hi, Ben Franksen benjamin.frank...@bessy.de writes: This rc release is still notably slower on some operations than older releases. My test case is a large project named RTEMS (a real-time OS), that we wish to import into darcs (at work) to better track our own additions and modifications.

Re: [Haskell-cafe] A small oversight

2010-02-20 Thread Daniel Fischer
Am Samstag 20 Februar 2010 13:39:24 schrieb Ben Millwood: a technique which I believe is called a Schwarzian transform. Schwartzian transform, with a tz. After Randal L. Schwartz. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

[Haskell-cafe] ANN: HaskellTorrent v0.0

2010-02-20 Thread Jesper Louis Andersen
Hello, I am happy to announce HaskellTorrent v0.0, a concurrent bittorrent client. The current release is a rather early preview release: it can download torrents and seed them, but currently there are many optimizations and tweaks needed before it is ready for day-to-day use. In particular, we

[Haskell-cafe] Restricted categories

2010-02-20 Thread Sjoerd Visscher
Hi all, I want restricted categories, just like the rmonad package provides restricted monads. The ultimate goal is to have a product category: http://en.wikipedia.org/wiki/Product_category {-# LANGUAGE TypeOperators, TypeFamilies, MultiParamTypeClasses, FlexibleInstances, FlexibleContexts,

Re: [Haskell-cafe] Category Theory woes

2010-02-20 Thread Nick Rudnick
A place in the hall of fame and thank you for mentioning clopen... ;-) Just wanting to present open/closed as and example of improvable maths terminology, I oversaw this even more evident defect in it and even copied it into my improvement proposal, bordered/unbordered: It is questionable

Re: [Haskell-cafe] Category Theory woes

2010-02-20 Thread Nick Rudnick
Richard O'Keefe wrote: On Feb 19, 2010, at 2:48 PM, Nick Rudnick wrote: Please tell me the aspect you feel uneasy with, and please give me your opinion, whether (in case of accepting this) you would rather choose to consider Human as referrer and Int as referee of the opposite -- for I think

[Haskell-cafe] Re: Heterogeneous Data Structures - Nested Pairs and functional references

2010-02-20 Thread Heinrich Apfelmus
Alexander Solla wrote: So, the type (View view) -- ignoring class instances -- is basically isomorphic to this (slightly simpler) type: data View = EmptyView | TextView String | ConcatView View View | NestViews View View View | ... instance Monoid View where ... Now, consider the

Re: [Haskell-cafe] Restricted categories

2010-02-20 Thread Alexander Solla
On Feb 20, 2010, at 10:29 AM, Sjoerd Visscher wrote: I don't understand this, as I thought the constraints the error is complaining about is just what withConstraintsOf g should provide. I guess there's something about the Suitable trick that I don't understand, or possibly the type

Re: [Haskell-cafe] Pointfree composition for higher arity

2010-02-20 Thread Matt Hellige
On Fri, Feb 19, 2010 at 10:42 PM, wren ng thornton w...@freegeek.org wrote: Sean Leather wrote: The second option approaches the ideal pointfreeness (or pointlessness if you prefer), but I'd like to go farther: (...) :: (c - d) - (a - b - c) - a - b - d (...) f g x y = f (g x y) infixr 9

[Haskell-cafe] ANNOUNCE: ioctl 0.0.1

2010-02-20 Thread Maciej Piechotka
A package for type-safe I/O control. Currently only ioctl is supported. Currently simply a extract from my tuntap fork TODO: - Return the integer as well as structure (will break the API) - Port for Windows Network.Socket.IOCtl (as soon as I manage to setup some sane environment on this

Re: [Haskell-cafe] Re: Heterogeneous Data Structures - Nested Pairs and functional references

2010-02-20 Thread Alexander Solla
On Feb 20, 2010, at 10:25 AM, Heinrich Apfelmus wrote: But isn't the line renderXHtml (ConcatView l r) = fold $ renderXHtml (ConcatViews l r) a type error? I'm assuming Data.Foldable.fold :: (Foldable m, Monoid t) = m t - t being applied to the result type of renderXHtml which is

Re: [Haskell-cafe] Pointfree composition for higher arity

2010-02-20 Thread wren ng thornton
Matt Hellige wrote: Thanks! I'm glad to know that people have found this approach useful. In cases where it works, I find it somewhat cleaner than families of combinators with (what I find to be) rather obscure names, or much worse, impenetrable sections of (.). We can write the original example

Re: [Haskell-cafe] Restricted categories

2010-02-20 Thread Nick Rudnick
Alexander Solla wrote: You specifically ask withConstraintsOf to accept only Suitable2's when you say withConstraintsOf :: Suitable2 m a b = m a b - (Constraints m a b - k) - k But you aren't saying that the argument of withConstraintsOf IS a Suitable2, when you say: instance (RCategory c1,

Re: [Haskell-cafe] A small oversight

2010-02-20 Thread Leon Smith
On Sat, Feb 20, 2010 at 5:47 AM, Andrew Coppin andrewcop...@btinternet.com wrote:  sortOn :: (Ord y) = (x - y) - [x] - [x]  sortOn foo = sortBy (compare `on` foo) Incidentally, this function is provided as Data.List.Ordered.sortOn' in the data-ordlist package... On Sat, Feb 20, 2010 at