Re: [Haskell-cafe] HDF5 binding (was: why is ghci trying to load hsc file ??)

2011-03-02 Thread James Andrew Cook
What an interesting coincidence, that makes at least three of us. Apparently it's an idea whose time has come. Mine is also an incomplete low-level binding but is currently under semi-active development and I aim to make it cover the entire hdf5.h interface. If anyone is interested in it I've

Re: [Haskell-cafe] Sub-optimal [code]

2011-02-16 Thread James Andrew Cook
On Feb 15, 2011, at 6:05 PM, Daniel Fischer daniel.is.fisc...@googlemail.com wrote: On Tuesday 15 February 2011 23:29:39, Andrew Coppin wrote: Ouch! I suppose what we could really do with is a combinator that runs a monadic action N times, without actually constructing a list N elements

Re: [Haskell-cafe] Are newtypes optimised and how much?

2010-10-20 Thread James Andrew Cook
On Oct 20, 2010, at 11:58 AM, Gregory Crosswhite gcr...@phys.washington.edu wrote: On 10/20/10 4:09 AM, Simon Peyton-Jones wrote: No, this isn't optimised. The trouble is that you write (map Foo xs), but GHC doesn't know about 'map'. We could add a special case for map, but then you'd

Re: [Haskell-cafe] Are newtypes optimised and how much?

2010-10-20 Thread James Andrew Cook
On Oct 20, 2010, at 5:06 PM, Thomas Schilling nomin...@googlemail.com wrote: Do we really want to treat every newtype wrappers as a form of 'id'? For example: newtype Nat = Nat Integer -- must always be positive A possible rule (doesn't actually typecheck, but you get the idea):

Re: [Haskell-cafe] example in All about Monads

2010-09-20 Thread James Andrew Cook
Also keep in mind that Maybe is a sort of a toy example of the concept being developed. It is indeed useful as a monad in its own right, but certainly not a case where the comb function is absolutely essential, as wren demonstrated. There are stronger motivations for using the 'comb' approach

Re: [Haskell-cafe] Ultra-newbie Question

2010-09-20 Thread James Andrew Cook
On Sep 20, 2010, at 5:10 AM, Jean-Marie Gaillourdet wrote: Hi Alberto, On 20.09.2010, at 10:53, Alberto G. Corona wrote: 2010/9/18 Daniel Fischer daniel.is.fisc...@web.de n_lastn n = reverse . take n . reverse Which is the most elegant definition, but it's an O(length list) space

Re: [Haskell-cafe] Ultra-newbie Question

2010-09-20 Thread James Andrew Cook
On Sep 20, 2010, at 9:49 AM, Daniel Fischer wrote: which I am inclined to believe. Your 'f' should also run in O(1) space. Alas, no. At least with GHC (and I don't see how it could be otherwise), reverse is always an O(length xs) space operation. reverse :: [a] - [a]

Re: [Haskell-cafe] Re: ANNOUNCE: grammar-combinators 0.1 (initial release): A parsing library of context-free grammar combinators

2010-09-08 Thread James Andrew Cook
On Sep 8, 2010, at 7:49 AM, Johannes Waldmann wrote: then you'll get more static guarantees (e.g., context-freeness) but you need extra (type-level, or even syntax-level) machinery to handle grammars. Convince me that it's worth it ... Those guarantees, along with just the fact that the

Re: [Haskell-cafe] Re: Unwrapping newtypes

2010-09-08 Thread James Andrew Cook
On Sep 8, 2010, at 8:19 AM, Kevin Jardine wrote: Hi Tony, I stared at that specific section for at least half an hour earlier today but could not figure out how it applied in my specific case. The only examples I have see are for deriving Num. Do you have any more detail on how I could use

Re: [Haskell-cafe] Re: ghc HEAD

2010-09-08 Thread James Andrew Cook
In many cases it would make quite a lot of sense for the developer to be able to specify default flags as well, preferably without resorting to including a C file. Generally, the developer will know better than the user whether it makes sense to include -N, the various thread affinity options,

Re: [Haskell-cafe] random-fu confusion

2010-09-07 Thread James Andrew Cook
A PureMT generator is immutable, so must be threaded through the monad in which you are sampling. There are RandomSource instances provided for a few special cases, including IORef PureMT in the IO monad. For example: main = do mt - newPureMT src - newIORef mt flips - runRVar

Re: Searching for Haskell (was: [Haskell-cafe] Slightly humorous: Headhunters toolbox (example for Germany))

2010-09-07 Thread James Andrew Cook
On Aug 31, 2010, at 1:57 PM, Alberto G. Corona wrote: What happened in the first half of 2006? monads were high there!. Wasn't that about the time Microsoft was previewing the Power Shell, codenamed Monad? -- James___ Haskell-Cafe

Re: [Haskell-cafe] random-fu confusion

2010-09-07 Thread James Andrew Cook
On Sep 7, 2010, at 10:21 AM, Alex Rozenshteyn wrote: Okay, I figured the immutability bit out and I got the IORef example working, but I can't get it to work with state. put (pureMT 0) = runRVar flipCoin gives me two type errors: No instance for (MonadState PureMT m) and No instance

Re: [Haskell-cafe] Wildly off-topic: de Boor's algorithm

2010-08-06 Thread James Andrew Cook
On Aug 5, 2010, at 4:31 PM, Andrew Coppin wrote: mo...@deepbondi.net wrote: Andrew Coppin wrote: Given a suitable definition for Vector2 (i.e., a 2D vector with the appropriate classes), it is delightfully trivial to implement de Casteljau's algorithm: de_Casteljau :: Scalar -

Re: [Haskell-cafe] ANN: random-fu 0.1.0.0

2010-06-07 Thread James Andrew Cook
On Jun 4, 2010, at 9:42 PM, wren ng thornton wrote: ---unless, perhaps, you have a way of deriving a definition of rvarT from rvar. If so, then there could be efficiency issues in the other direction. I could see some people just giving a pretty implementation of rvar and using the

Re: [Haskell-cafe] ANN: random-fu 0.1.0.0

2010-06-04 Thread James Andrew Cook
On Jun 3, 2010, at 10:03 PM, wren ng thornton wrote: Though, since RVar is a synonym for RVarT, I can't imagine why rvar is a method instead of a shorthand defined outside of the class. (If RVar were primitive then I could imagine performance reasons, but since it isn't...) The reason for

Re: [Haskell-cafe] ANN: random-fu 0.1.0.0

2010-06-04 Thread James Andrew Cook
On Jun 4, 2010, at 1:19 AM, Alexander Solla wrote: We don't necessarily have to compute the inverse of the distribution via sampling to do it. It can be done algebraically, in terms of the convolution operator. Since the types are enumerated, wouldn't something like... work? -- A set

Re: [Haskell-cafe] Re: True Random Numbers

2010-04-14 Thread James Andrew Cook
I have now had a chance to experiment with these a bit, and have come up with some changes that bring random-fu's speed in these tests into line with Control.Monad.Random's when compiled with ghc-6.12.1, although it is still a bit slower when using GHC 6.10.4. This is partially because one of

Re: [Haskell-cafe] Re: True Random Numbers

2010-04-09 Thread James Andrew Cook
Thanks for the clues, I'll try and make some time this weekend to track it down. I do have some gentoo x64 systems to play with. My first impulse is actually that it is likely due to differences in inlining and/or rewrite rule processing between the GHC versions, but we'll see what turns up.