Re: [Haskell-cafe] abs minBound (0 :: Int) negate minBound == (minBound :: Int)

2013-08-21 Thread Ketil Malde

 fact 0 = 1
 fact n = n * fact (n-1)

 Now I ran it as fact 100 with signature Int - Int and with
 Integer - Integer

 In the first case I got 0 in about 3 seconds
  [...]
 And if that sounds like a unreal argument, consider representing and
 storing Graham's number.

So, since computers are finite anyway, we can just arbitrarily (well,
almost) redefine large constants, and set all factorials above some
threshold to zero?  Perhaps we should also set pi=3, that would simplify
lots of things :-)

 Pragmatically: 32-bits is unwise for a bank-balance, 64 should be a
 bit more safe

Please start a bank using modulo arithmetic, I'm looking forward to
overdrafting my account!  

 So yes, Haskell's Int, should have been called FastInt or Int29 or somethin'

On a more serious note, I accept that Int (and other limited precision
numbers) is a fact of life, and sometimes useful for performance
reasons.  

I would have liked, however, to have a compiler option or some other way
to make my programs throw an exception on overflow - even if this turned
out to be slower, I could at least use it when testing my programs,
which would have caught a few bugs.

-k
-- 
If I haven't seen further, it is by standing in the footprints of giants

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] GHC and backwards compatibility

2013-08-21 Thread Henning Thielemann

If you use

$ cabal install --constraint=array installed

then cabal-install is forced to use the installed version of array. If a 
package conflicts with this version, then it will report the conflicting 
packages.


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] abs minBound (0 :: Int) negate minBound == (minBound :: Int)

2013-08-21 Thread Rustom Mody
On Wed, Aug 21, 2013 at 11:47 AM, Ketil Malde ke...@malde.org wrote:
 On a more serious note, I accept that Int (and other limited precision
 numbers) is a fact of life, and sometimes useful for performance
 reasons.

 I would have liked, however, to have a compiler option or some other way
 to make my programs throw an exception on overflow - even if this turned
 out to be slower, I could at least use it when testing my programs,
 which would have caught a few bugs.

Yes for software detection, some will want it and some will not; see
the same discussion a few months ago
http://www.haskell.org/pipermail/haskell-cafe/2013-June/107153.html

The 'some other way' is hardware detection.  And there is glimmer of
hope that Intel may begin to do due diligence
http://www.emulators.com/docs/LazyOverflowDetect_Final.pdf

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] PPC binaries for GHC 7.x?

2013-08-21 Thread Rogan Creswick
Does anyone have PPC binaries for GHC 7.x?

I've been trying to help a PPC user compile a large haskell application,
and it (and it's dependencies) require a newer ghc; the latest ppc binaries
we've found are for 6.10, and we have been unable to compile a never ghc
from source (6.12 /almost/ worked, but eventually failed with a linker
error that appears to be unsolvable in the near-term).

Thanks!
Rogan
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] PPC binaries for GHC 7.x?

2013-08-21 Thread Joey Adams
On Wed, Aug 21, 2013 at 4:55 AM, Rogan Creswick cresw...@gmail.com wrote:

 Does anyone have PPC binaries for GHC 7.x?

 I've been trying to help a PPC user compile a large haskell application,
 and it (and it's dependencies) require a newer ghc; the latest ppc binaries
 we've found are for 6.10, and we have been unable to compile a never ghc
 from source (6.12 /almost/ worked, but eventually failed with a linker
 error that appears to be unsolvable in the near-term).


What operating system?

Debian Wheezy (stable) supports PowerPC, and has a working GHC 7.4.1.  You
can also try unstable (sid).  Don't install sid packages on stable (I ran
into linker errors with direct-sqlite when I tried that).
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] PPC binaries for GHC 7.x?

2013-08-21 Thread Rogan Creswick
On Wed, Aug 21, 2013 at 2:29 AM, Joey Adams joeyadams3.14...@gmail.comwrote:


 What operating system?


Oh, I should have specified -- OS X (I'm not certain which version of OS X;
probably not particularly new)

--Rogan
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Ideas on a fast and tidy CSV library

2013-08-21 Thread Justin Paston-Cooper
Dear All,

I now have some example code. I have put it on: http://pastebin.com/D9MPmyVd.

vectorBinner is simply of type Vector Int - Int. I am inputting a 1.5GB
CSV on stdin, and would like vectorBinner to run over every single record,
outputting results as computed, thus running in constant memory. My
programme instead quickly approaches full memory use. Is there any way to
work around this?

Justin


On 25 July 2013 17:53, Johan Tibell johan.tib...@gmail.com wrote:

 You can use the Incremental or Streaming modules to get more fine
 grained control over when new parsed records are produced.

 On Thu, Jul 25, 2013 at 11:02 AM, Justin Paston-Cooper
 paston.coo...@gmail.com wrote:
  I hadn't yet tried profiling the programme. I actually deleted it a few
 days
  ago. I'm going to try to get something new running, and I will report
 back.
  On a slightly less related track: Is there any way to use cassava so
 that I
  can have pure state and also yield CSV lines while my computation is
 running
  instead of everything at the end as would be with the State monad?
 
 
  On 23 July 2013 22:13, Johan Tibell johan.tib...@gmail.com wrote:
 
  On Tue, Jul 23, 2013 at 5:45 PM, Ben Gamari bgamari.f...@gmail.com
  wrote:
   Justin Paston-Cooper paston.coo...@gmail.com writes:
  
   Dear All,
  
   Recently I have been doing a lot of CSV processing. I initially tried
   to
   use the Data.Csv (cassava) library provided on Hackage, but I found
   this to
   still be too slow for my needs. In the meantime I have reverted to
   hacking
   something together in C, but I have been left wondering whether a
 tidy
   solution might be possible to implement in Haskell.
  
   Have you tried profiling your cassava implementation? In my experience
   I've found it's quite quick. If you have an example of a slow path I'm
   sure Johan (cc'd) would like to know about it.
 
  I'm always interested in examples of code that is not running fast
  enough. Send me a reproducible example (preferably as a bug on the
  GitHub bug tracker) and I'll take a look.
 
 

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Ideas on a fast and tidy CSV library

2013-08-21 Thread Johan Tibell
As I mentioned, you want to use the Streaming (or Incremental) module.
As the program now stands the call to `decode` causes 1.5 GB of CSV
data to be read as a `Vector (Vector Int)` before any encoding starts.

-- Johan


On Wed, Aug 21, 2013 at 1:09 PM, Justin Paston-Cooper
paston.coo...@gmail.com wrote:
 Dear All,

 I now have some example code. I have put it on: http://pastebin.com/D9MPmyVd
 .

 vectorBinner is simply of type Vector Int - Int. I am inputting a 1.5GB CSV
 on stdin, and would like vectorBinner to run over every single record,
 outputting results as computed, thus running in constant memory. My
 programme instead quickly approaches full memory use. Is there any way to
 work around this?

 Justin


 On 25 July 2013 17:53, Johan Tibell johan.tib...@gmail.com wrote:

 You can use the Incremental or Streaming modules to get more fine
 grained control over when new parsed records are produced.

 On Thu, Jul 25, 2013 at 11:02 AM, Justin Paston-Cooper
 paston.coo...@gmail.com wrote:
  I hadn't yet tried profiling the programme. I actually deleted it a few
  days
  ago. I'm going to try to get something new running, and I will report
  back.
  On a slightly less related track: Is there any way to use cassava so
  that I
  can have pure state and also yield CSV lines while my computation is
  running
  instead of everything at the end as would be with the State monad?
 
 
  On 23 July 2013 22:13, Johan Tibell johan.tib...@gmail.com wrote:
 
  On Tue, Jul 23, 2013 at 5:45 PM, Ben Gamari bgamari.f...@gmail.com
  wrote:
   Justin Paston-Cooper paston.coo...@gmail.com writes:
  
   Dear All,
  
   Recently I have been doing a lot of CSV processing. I initially
   tried
   to
   use the Data.Csv (cassava) library provided on Hackage, but I found
   this to
   still be too slow for my needs. In the meantime I have reverted to
   hacking
   something together in C, but I have been left wondering whether a
   tidy
   solution might be possible to implement in Haskell.
  
   Have you tried profiling your cassava implementation? In my
   experience
   I've found it's quite quick. If you have an example of a slow path
   I'm
   sure Johan (cc'd) would like to know about it.
 
  I'm always interested in examples of code that is not running fast
  enough. Send me a reproducible example (preferably as a bug on the
  GitHub bug tracker) and I'll take a look.
 
 



___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] ANN: Google co-sponsoring ZuriHac 2013

2013-08-21 Thread Bas van Dijk
Dear Haskellers,

I would like to remind you that the Zurich FP Afternoon (with a
keynote by Simon Marlow) is taking place next week (13:00, Thursday,
29 August) and is directly followed by the ZuriHac 2013 Haskell
Hackathon [1].

There are still some places available at both events -- you're welcome
to register at:

http://bit.ly/ZuriHac2013Reg

Google Switzerland will co-sponsor the FP Afternoon and ZuriHac 2013
together with ETH Zurich and Erudify.

Their sponsorship means we can give each attendee a free t-shirt
(picture on the wikipage [2]) and free food and drinks during the FP
Afternoon.

Google is also offering a quiz during the FP Afternoon with prizes
including a Galaxy S4 mini.

I hope to see you there!

Bas

[1] http://www.haskell.org/haskellwiki/ZuriHac2013
[2] http://www.haskell.org/haskellwiki/ZuriHac2013#News

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] haskore - lilypond - typesetting?

2013-08-21 Thread Johannes Waldmann
I tried using lilypond ( http://www.lilypond.org/ ) 
for typesetting of sheet music.

While the output looks nice, the input language IMHO is quite horrible,
because the underlying data/execution model is underspecified.
For some parts, it tries to describe the logical structure of the score; 
but for others, the layout; and in addition it has several non-obvious 
context-dependencies (but see below), preventing modularity.

Is there a better option? E.g., starting from a clear mathematical model,
as in Haskore, and use lilypond only as a PDF rendering engine?

Do I want hly / hts perhaps?  http://rd.slavepianos.org/?t=hly


As I see it, the main high-level design problem 
is that the source language needs partial evaluation annotations
for abstractions applications: sometimes they should be expanded 
(for MIDI rendering, always) and sometimes not (in typesetting, 
to create repetition marks instead of actually repeating notes). 


PS: I agree that some of lilypond's context dependencies 
(relative pitch, implicit note length) do really save 
large amounts of tedious typing: c4 e g a c1 is much more economical 
than [c 1 qn, e 1 qn, g 1 qn , a 1 qn, c 2 fn] 
which I guess is the Haskore equivalent.




___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] haskore - lilypond - typesetting?

2013-08-21 Thread Rustom Mody
On Wed, Aug 21, 2013 at 6:35 PM, Johannes Waldmann
waldm...@imn.htwk-leipzig.de wrote:
 I tried using lilypond ( http://www.lilypond.org/ )
 for typesetting of sheet music.

 While the output looks nice, the input language IMHO is quite horrible,

I use musescore.
Its got 3 modes on entry
a. clickety-click -- ie mouse
b. keyboard shortcuts
c. midi keyboard

For bulk entry direct entry from a midi keyboard is best
http://musescore.org/en/handbook/note-entry
[Since I am not much of a musician, I usually hover between a and b]

If after that you want the lilypond toolchain, it will export to
lilypond and then use your favorite text editor. [Not sure of the
quality of export]

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] abs minBound (0 :: Int) negate minBound == (minBound :: Int)

2013-08-21 Thread Evan Laforge
 but Integer is actually (if you're using GMP with your ghc):

 Yes, that's tolerably well known.  You only pay the space overhead
 when you need it (like Lisp or Smalltalk).  But you always pay the
 time overhead.

I thought Integers can't be unboxed, regardless of their magnitude?

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] What am I missing? Cycle in type synonym declarations

2013-08-21 Thread Simon Peyton-Jones
GHC tries to typecheck quotations.  In this case it's trying to typecheck the 
declaration
type Bar = FooT $t
Part of type checking is rejecting recursive type synonyms.  Here GHC is 
rejecting it because it *might* be recursive, depending on how $t is filled in.

The trouble is that we really *can't*  typecheck partial declarations like this 
one.  All this will be fixed when we fold in the new Template Haskell story 
(it'll be in 7.8).  See my blog post on the GHC Trac (from about 2 yrs ago) 
describing the change.  (I'm on a train so don't know the URL.)  Geoff has made 
the change... it just needs to be merged in.

Simon

|  -Original Message-
|  From: Haskell-Cafe [mailto:haskell-cafe-boun...@haskell.org] On Behalf Of 
David
|  Fox
|  Sent: 20 August 2013 22:00
|  To: Haskell Cafe
|  Subject: [Haskell-cafe] What am I missing? Cycle in type synonym declarations
|  
|  This file gives me the error Cycle in type synonym declarations  Can
|  anyone tell me why?  I'm just trying to write a function to create a
|  type that is a FooT with the type parameter fixed.
|  
|  {-# LANGUAGE TemplateHaskell #-}
|  import Language.Haskell.TH (Q, Dec, TypeQ)
|  
|  data FooT a = FooT a
|  
|  foo :: TypeQ - Q [Dec]
|  foo t = [d| type Bar = FooT $t |]
|  
|  ___
|  Haskell-Cafe mailing list
|  Haskell-Cafe@haskell.org
|  http://www.haskell.org/mailman/listinfo/haskell-cafe


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] haskore - lilypond - typesetting?

2013-08-21 Thread Sturdy, Ian
I think the big question is whether you are dealing with music or scores. a .ly 
file represents not the music, but the music plus typographic annotations (and 
I find that even lilypond quite often benefits from hints). Most gui programs 
represent scores, but I think lilypond stands alone in that among text formats. 
So the question, to me, is whether you need a representation of music, or of a 
score; if of music, I would choose an input format other than lilypond (abc 
recommends itself from my folk-music background), using an appropriate backend 
for rudimentary typesetting. But if you need the full layout flexibility, I 
doubt you can beat writing straight lilypond: I have yet to see a frontend 
produce easily hand-edited lilypond source (which I find very quickly becomes a 
featureless blob without judicious use of whitespace), nor one that exposes the 
flexibility of the lilypond engine (and I find lilypond much faster to write 
than Finale, and little slower than Mozart's superb keyboar
 d entry (not being a keyboardist, I cannot speak for midi entry)). haskore and 
hly I would reserve for internal representations for conversion or 
transformation programs; I think there are much better alternatives for human 
writing.

I would also be careful with excessively mathematical representations; before 
finding lilypond, I had to discard more than one program for failure to handle 
irregular meters.



From: Haskell-Cafe [haskell-cafe-boun...@haskell.org] on behalf of Rustom Mody 
[rustompm...@gmail.com]
Sent: Wednesday, August 21, 2013 10:46 AM
To: Johannes Waldmann
Cc: Haskell Cafe
Subject: Re: [Haskell-cafe] haskore - lilypond - typesetting?


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] haskore - lilypond - typesetting?

2013-08-21 Thread Stephen Tetley
Here's one I did earlier...

http://www.flickr.com/photos/44929957@N03/4459628487/lightbox/

This is Haskore implementation of Chick Corea's Child Song 6 rendered to
LilyPond - I don't imagine Mr. Corea's publishers will be sending me a
takedown request any time soon.

There's a lot missing from Haskore that is needed to make good scores - the
renderer of the above took a lot of effort with metrical grouping but the
result is still abysmal.

I doubt mathematics can help (common practice) music typesetting much -
Western notation has had a thousand years to develop without the constraint
of a regular syntax; so if Lilypond is horrible it is mostly the fault of
what it tries to typeset (it does make some unwarranted mistakes like
over-restricting the characters it can use for variable names and its
parenthesizing is horrible).


On 21 August 2013 14:05, Johannes Waldmann waldm...@imn.htwk-leipzig.dewrote:

 I tried using lilypond ( http://www.lilypond.org/ )
 for typesetting of sheet music.

 While the output looks nice, the input language IMHO is quite horrible,
 because the underlying data/execution model is underspecified.
 For some parts, it tries to describe the logical structure of the score;
 but for others, the layout; and in addition it has several non-obvious
 context-dependencies (but see below), preventing modularity.

 Is there a better option? E.g., starting from a clear mathematical model,
 as in Haskore, and use lilypond only as a PDF rendering engine?

 Do I want hly / hts perhaps?  http://rd.slavepianos.org/?t=hly


 As I see it, the main high-level design problem
 is that the source language needs partial evaluation annotations
 for abstractions applications: sometimes they should be expanded
 (for MIDI rendering, always) and sometimes not (in typesetting,
 to create repetition marks instead of actually repeating notes).


 PS: I agree that some of lilypond's context dependencies
 (relative pitch, implicit note length) do really save
 large amounts of tedious typing: c4 e g a c1 is much more economical
 than [c 1 qn, e 1 qn, g 1 qn , a 1 qn, c 2 fn]
 which I guess is the Haskore equivalent.




 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] HSpec vs Tasty (was: ANN: hspec-test-framework - Run test-framework tests with Hspec)

2013-08-21 Thread Andrey Chudnov
So is there a high-level comparison of HSpec and tasty? The only 
difference I've glimpsed so far was that HSpec has a syntactic sugar for 
describing tests which, honestly, I haven't found very useful.
So, could someone write up a quick comparison of the two for the benefit 
of the folks like me who have a lot of test-framework tests and have to 
switch to either tasty or hspec?


On 08/18/2013 06:27 PM, Roman Cheplyaka wrote:

My answer to this and many similar questions regarding tasty is:

- I am probably not going to work on this
- but I would be happy to see someone doing it

Note that hspec-test-framework is a separate package, and it didn't have
to be written or even approved by Simon. Same here — please write more
supplementary packages if you feel a need.

Roman

* Alfredo Di Napoli alfredo.dinap...@gmail.com [2013-08-18 15:18:07+0200]

Hi Simon,

this is an exciting news!

May I ask the question that maybe is lurking in the shadow?

Due to the recent announcement of Roman's tasty library, are there plans
to basically release something similar to hspec-test-framework and
hspec-test-framework-th but targeting tasty instead?

Bye :)
A.


On 18 August 2013 14:50, Simon Hengel s...@typeful.net wrote:


Hi,
I just released hspec-test-framework[1] and hspec-test-framework-th[2]
to Hackage.

They can be used to run test-framework tests with Hspec unmodified.

This can also be used to work around test-framework's incompatibility
with QuickCheck-2.6 and base-4.7.0 ;)

Have a look at the README for usage instructions:

 https://github.com/sol/hspec-test-framework#readme

Cheers,
Simon

[1] http://hackage.haskell.org/package/hspec-test-framework
[2] http://hackage.haskell.org/package/hspec-test-framework-th

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe



___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe



___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Yet Another Forkable Class

2013-08-21 Thread John ExFalso
TLDR: New forkable monad/transformer suggestion
http://pastebin.com/QNUVL12v(hpaste is down)

Hi,

There are a dozen packages on hackage defining a class for monads that can
be forked, however none of these are modular enough to be useful in my
opinion.

In particular the following are not addressed:
1. Cases when the child thread's monad is different from the parent's
2. Monad transformers (this is somewhat addressed with
Control.Monad.Trans.Control)

I will try to demonstrate both issues with an example.

1. WebSockets

WebSockets is a monad that cannot itself be forked. This is because at any
given time there should only be a single thread listening on a websocket.
However there is a reasonable monad that can be forked off, namely one that
can send to the websocket - one that has access to the Sink.

So first off a Forkable class should not look like this:

class (MonadIO m, MonadIO n) = Forkable m where
fork :: m () - m ThreadId

But rather like this:

class Forkable m n where
fork :: n () - m ThreadId

For our example the instance would be

instance (Protocol p) = Forkable (WebSockets p) (ReaderT (Sink p) IO) where
fork (ReaderT f) = liftIO . forkIO . f = getSink

Another example would be a child that should not be able to throw errors as
opposed to the parent thread.

2. ReaderT

Continuing from the previous example to demonstrate the need to distinguish
forkable transformers.
Say we have some shared state S that both parent and child should have
access to:

type Parent p = ReaderT (TVar S) (WebSockets p)
type Child p = ReaderT (TVar S) (ReaderT (Sink p) IO)

The forkability of Child from Parent should be implied, however with
Forkable we have to write a separate instance.

So what I suggest is a second class:

class ForkableT t where
forkT :: (Forkable m n) = t n () - t m ThreadId

And then:

instance ForkableT (ReaderT r) where
forkT (ReaderT f) = ReaderT $ fork . f

We can also introduce a default for Forkable that uses a ForkableT instance:

class (MonadIO m, MonadIO n) = Forkable m n where
fork :: n () - m ThreadId
default fork :: ForkableT t = t n () - t m ThreadId
fork = forkT

instance (Forkable m n) = Forkable (ReaderT r m) (ReaderT r n)

This means Child is automatically Forkable from Parent, no need to write a
specific case for our specific monads (and if we newtype it we can use
-XGeneralizedNewtypeDeriving)

Note how MonadTransControl already solves the specific problem of lifting a
forking operation into ReaderT. However consider ResourceT from
Control.Monad.Resource: it is basically a ReaderT, however in order to
safely deallocate resources when sharing reference counting is needed. This
means a simple lift would not suffice.

We can nevertheless provide a default ForkableT based on MonadTransControl:
class ForkableT t where
forkT :: (Forkable m n) = t n () - t m ThreadId
default forkT :: (MonadTransControl t, Forkable m n) = t n () - t m
ThreadId
forkT t = liftWith $ \run - fork $ run t  return ()

Actually resourcet's reference counting resourceForkIO also nicely
demonstrates the first problem:
type Parent p = ResourceT (WebSockets p)
type Child p = ResourceT (ReaderT (Sink p) IO)

Note how we cannot use resourceForkIO without touching the underlying
monads.

What do you think? Is there already an established way of modular forking?
I wouldn't like to litter hackage with another unusable Forkable class:)
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Haskell Weekly News: Issue 277

2013-08-21 Thread Daniel Santa Cruz
Welcome to issue 277 of the HWN, an issue covering crowd-sourced bits
of information about Haskell from around the web. This issue covers the
week of August 11 to 17, 2013.

Quotes of the Week

   * psygnisfive: Seminearring is the task of giving seminars.

   * Taneb: You know you've made it when SPJ asks you for help with
 Haskell.

   * byorgey: . o O ( For my next trick, I will CPS-encode this
 rabbit! -- edwardk )

   * shachaf: I prefer the cogolden rule: When CPS-transforming, doubt.

   * edwardk: You see these scars? I got them back in 7.7.

   * danharaj: parsing is hard, let's go shopping

Top Reddit Stories

   * Mio: A High-Performance Multicore IO Manager for GHC [pdf]
 Domain: haskell.cs.yale.edu, Score: 147, Comments: 31
 On Reddit: [1] http://goo.gl/ZTy1Yl
 Original: [2] http://goo.gl/6foNWC

   * Destroying Performance with Strictness
 Domain: neilmitchell.blogspot.ru, Score: 92, Comments: 45
 On Reddit: [3] http://goo.gl/1rkx3a
 Original: [4] http://goo.gl/rb5UnM

   * A great series of posts on the power of monoids
 Domain: self.haskell, Score: 78, Comments: 10
 On Reddit: [5] http://goo.gl/TmAAwT
 Original: [6] http://goo.gl/TmAAwT

   * Cellular Automata by Edward Kmett
 Domain: fpcomplete.com, Score: 69, Comments: 7
 On Reddit: [7] http://goo.gl/EIFK5A
 Original: [8] http://goo.gl/03mNhV

   * Elm 0.9 - New type checker, much better error messages
 Domain: elm-lang.org, Score: 50, Comments: 14
 On Reddit: [9] http://goo.gl/ngSBPX
 Original: [10] http://goo.gl/4Jp3l6

   * Revisiting Matrix Multiplication, Part I by Edward Kmett
 Domain: fpcomplete.com, Score: 45, Comments: 4
 On Reddit: [11] http://goo.gl/gYfm5S
 Original: [12] http://goo.gl/bg75ZX

   * Revisiting Matrix Multiplication, Part II by Edward Kmett
 Domain: fpcomplete.com, Score: 37, Comments: 9
 On Reddit: [13] http://goo.gl/qU2r69
 Original: [14] http://goo.gl/5cRq72

   * Roles: a new feature of GHC (patch GND + type families)
 Domain: typesandkinds.wordpress.com, Score: 34, Comments: 28
 On Reddit: [15] http://goo.gl/HhVOTu
 Original: [16] http://goo.gl/Twx5YB

   * Type Inference, Haskell and Dependent Types :: PDF
 Domain: personal.cis.strath.ac.uk, Score: 33, Comments: 0
 On Reddit: [17] http://goo.gl/MbtYGO
 Original: [18] http://goo.gl/uOx01F

   * Embedded Languages for High-Performance Computing
 [Chakravarty, PDF 70 slides]
 Domain: speakerdeck.com, Score: 31, Comments: 4
 On Reddit: [19] http://goo.gl/mb2frN
 Original: [20] http://goo.gl/EEG0Wk

   * Graph drawing with gloss
 Domain: mazzo.li, Score: 30, Comments: 7
 On Reddit: [21] http://goo.gl/j0CZmo
 Original: [22] http://goo.gl/5ZtFuu

   * Benchmarking sqlite-simple against Python and C
 Domain: nurpax.github.io, Score: 28, Comments: 9
 On Reddit: [23] http://goo.gl/CNyjWa
 Original: [24] http://goo.gl/gFmWgT

   * What is lifting? Explained on stackoverflow
 Domain: stackoverflow.com, Score: 25, Comments: 7
 On Reddit: [25] http://goo.gl/HzXWb9
 Original: [26] http://goo.gl/hQxTce

   * GHC API: Interpreted, compiled and package modules
 Domain: parenz.wordpress.com, Score: 23, Comments: 0
 On Reddit: [27] http://goo.gl/xUeUYq
 Original: [28] http://goo.gl/llQsyE

   * Time to start writing on the new binding: SDL 2.0 release.
 Domain: lists.libsdl.org, Score: 22, Comments: 15
 On Reddit: [29] http://goo.gl/G0ut36
 Original: [30] http://goo.gl/MuO1uB

   * FP Complete's Haskell programming competition now accepting entries
 Domain: fpcomplete.com, Score: 21, Comments: 7
 On Reddit: [31] http://goo.gl/tbEBKG
 Original: [32] http://goo.gl/ADsrJ

   * Pretext by experiments and guesses
 Domain: fpcomplete.com, Score: 18, Comments: 15
 On Reddit: [33] http://goo.gl/oVpKIe
 Original: [34] http://goo.gl/2PFthz

Top StackOverflow Questions

   * Haskell random numbers suddenly start to “converge”
 after months of running
 votes: 30, answers: 1
 Read on SO: [35] http://goo.gl/oxUAQ5

   * Why does ghc generate so many useless-looking nested case expressions?
 votes: 10, answers: 1
 Read on SO: [36] http://goo.gl/6cdTd1

Until next time,
[37]+Daniel Santa Cruz

References

   1.
http://haskell.cs.yale.edu/wp-content/uploads/2013/08/hask035-voellmy.pdf
   2.
http://www.reddit.com/r/haskell/comments/1k6fsl/mio_a_highperformance_multicore_io_manager_for/
   3.
http://neilmitchell.blogspot.ru/2013/08/destroying-performance-with-strictness.html
   4.
http://www.reddit.com/r/haskell/comments/1ker84/destroying_performance_with_strictness/
   5.
http://www.reddit.com/r/haskell/comments/1ka4q6/a_great_series_of_posts_on_the_power_of_monoids/
   6.
http://www.reddit.com/r/haskell/comments/1ka4q6/a_great_series_of_posts_on_the_power_of_monoids/
   7. https://www.fpcomplete.com/user/edwardk/cellular-automata
   8.

Re: [Haskell-cafe] Yet Another Forkable Class

2013-08-21 Thread oleg

Perhaps effect libraries (there are several to choose from) could be a
better answer to Fork effects than monad transformers. One lesson from
the recent research in effects is that we should start thinking what
effect we want to achieve rather than which monad transformer to
use. Using ReaderT or StateT or something else is an implementation
detail. Once we know what effect to achieve we can write a handler, or
interpreter, to implement the desired operation on the World, obeying
the desired equations. And we are done.

For example, with ExtEff library with which I'm more familiar, the
Fork effect would take as an argument a computation that cannot throw
any requests. That means that the parent has to provide interpreters
for all child effects. It becomes trivially to implement:

 Another example would be a child that should not be able to throw errors as
 opposed to the parent thread.
It is possible to specify which errors will be allowed for the child
thread (the ones that the parent will be willing to reflect and
interpret). The rest of errors will be statically prohibited then.

 instance (Protocol p) = Forkable (WebSockets p) (ReaderT (Sink p) IO) where
 fork (ReaderT f) = liftIO . forkIO . f = getSink

This is a good illustration of too much implementation detail. Why do we
need to know of (Sink p) as a Reader layer? Would it be clearer to
define an Effect of sending to the socket? Computation's type will
make it patent the computation is sending to the socket.
The parent thread, before forking, has to provide a handler for that
effect (and the handler will probably need a socket). 

Defining a new class for each effect is possible but not needed at
all. With monad transformers, a class per effect is meant to hide the
ordering of transformer layers in a monad transformer stack. Effect
libraries abstract over the implementation details out of the
box. Crutches -- extra classes -- are unnecessary. We can start by
writing handlers on a case-by-case basis. Generalization, if any,
we'll be easier to see. From my experience, generalizing from concrete
cases is easier than trying to write a (too) general code at the
outset. Way too often, as I read and saw, code that is meant to be
reusable ends up hardly usable.




___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Retrieving Haddock comments with haskell-src-exts

2013-08-21 Thread AntC
 Niklas Broberg niklas.broberg at gmail.com writes:
 
 Hmm. I see the difficulty here, ...

 
 On Wed, Aug 14, 2013 at 8:57 PM, Mateusz Kowalczyk wrote:
 ...
 The main problem with this approach is that we get comments (and their
 SrcLoc) as a separate list.

Hi Niklas, Mateusz,

It seems that haskell-src-exts has done quite a lot of the hard work 
(impressive!). 

Function parseFileWithComments returns the AST annotated with SrcLoc for 
each major node, and with a separate list of comments annotated with 
SrcSpan. So it should be possible to reconstitute the source and 
intersperse the comments between the nodes(?) -- or detect where a comment 
spans code.

(I'm also looking at the discussion about comments on Niklas's 
announcement of 1.14.0 )

Could there be a style of prettyPrint that carries the list of comments 
(as a continuation) alongside walking the AST, and consumes/outputs each 
comment where the comment's Span falls between the nodes' Loc? Would this 
need too much lookahead?

(And thank you to Adam for introducing me to the joys of source-munging. 
http://www.haskell.org/pipermail/haskell-cafe/2013-August/108426.html .)

AntC


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe