[Haskell-cafe] Higher order functions and strictness
tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk
Fri Dec 6 20:52:59 UTC 2013
On Fri, Dec 06, 2013 at 05:51:03PM +0000, Joachim Breitner wrote:
> But since I had been looking at some unboxed tuples recently, I noticed
> that the singleton unboxed tuple allows for exactly that: Call a
> function in a way that it has control (i.e. can force stuff), but do not
> necessarily evaluate its result, and all that without extra allocations.
This is a very, very neat observation! It seems that the unboxed singleton
allows fine grained control over order of evaluation without imposing any
datastructure overhead. I am (very slowly) working on an alternative
type-system for GHC which will make it look like a strict language with
explicit thunk datatype (although it will still be good old GHC under the
hood). Your observation will be helpful for performance.
> Of course (#..#) has it downsides, e.g. you cannot make a newtype for it
> (newtype Box a = (# x #)) does not work...
This is a shame, although it seems like in principle it may be possible
Still if SPJ's 'brain is too small to figure out all the ramifications of
dropping the "newtypes are always boxed" assumption' then I don't hold out
much hope that /anyone/ will be able to do anything about this restriction :)
More information about the Haskell-Cafe