<p dir="ltr">In an effort to build an Haskell client library for the Firebase service [0], which rely heavily on HTTP event source/server sent events [1], I am looking for an HTTP client lib supporting this spec.</p>
<p dir="ltr">AFAIK, both WAI and yesod handle the mechanism server-side but nor http-client, wreq or http-streams seem to provide the client counterpart.</p>
<p dir="ltr">Am I looking in the wrong direction?</p>
<p dir="ltr">SSE are basically '\n' separated yaml messages over a kept open http response stream. I guess a seasoned Haskell dev could build a solution quite easily but o couldn't find a way to keep the response stream opened.</p>
<p dir="ltr">Ideally a conduit/pipe sink exposing each message could be exposed for further parsing and usage.</p>
<p dir="ltr">I'd be very glassful of someone could help me contribute such handling or come up with a solution.</p>
<p dir="ltr">Thanks for your time,<br>
Alexandre</p>
<p dir="ltr">[0] <a href="https://www.firebase.com/docs/rest/api/">https://www.firebase.com/docs/rest/api/</a><br>
[1] <a href="http://www.w3.org/TR/2011/WD-eventsource-20110208/">http://www.w3.org/TR/2011/WD-eventsource-20110208/</a></p>
<div class="gmail_quote">Le 29 avr. 2015 14:02, <<a href="mailto:haskell-cafe-request@haskell.org">haskell-cafe-request@haskell.org</a>> a écrit :<br type="attribution"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Send Haskell-Cafe mailing list submissions to<br>
<a href="mailto:haskell-cafe@haskell.org">haskell-cafe@haskell.org</a><br>
<br>
To subscribe or unsubscribe via the World Wide Web, visit<br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br>
or, via email, send a message with subject or body 'help' to<br>
<a href="mailto:haskell-cafe-request@haskell.org">haskell-cafe-request@haskell.org</a><br>
<br>
You can reach the person managing the list at<br>
<a href="mailto:haskell-cafe-owner@haskell.org">haskell-cafe-owner@haskell.org</a><br>
<br>
When replying, please edit your Subject line so it is more specific<br>
than "Re: Contents of Haskell-Cafe digest..."<br>
<br>
<br>
Today's Topics:<br>
<br>
1. Re: Coplanarity or Colinearity [Was: low-cost matrix rank?]<br>
(Richard A. O'Keefe)<br>
2. Re: Prime sieve and Haskell demo (Doug McIlroy)<br>
3. Re: Prime sieve and Haskell demo (Kim-Ee Yeoh)<br>
4. Wiki user (fr33domlover)<br>
5. Re: Wiki user (Henk-Jan van Tuyl)<br>
6. Re: Wiki user (fr33domlover)<br>
7. Re: dependent types, singleton types.... (Richard Eisenberg)<br>
<br>
<br>
----------------------------------------------------------------------<br>
<br>
Message: 1<br>
Date: Wed, 29 Apr 2015 13:14:36 +1200<br>
From: "Richard A. O'Keefe" <<a href="mailto:ok@cs.otago.ac.nz">ok@cs.otago.ac.nz</a>><br>
To: Mike Meyer <<a href="mailto:mwm@mired.org">mwm@mired.org</a>><br>
Cc: Haskell-Cafe <<a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a>><br>
Subject: Re: [Haskell-cafe] Coplanarity or Colinearity [Was: low-cost<br>
matrix rank?]<br>
Message-ID: <<a href="mailto:28B3FCD1-5BE8-4769-8BA9-A20D8426F4C2@cs.otago.ac.nz">28B3FCD1-5BE8-4769-8BA9-A20D8426F4C2@cs.otago.ac.nz</a>><br>
Content-Type: text/plain; charset=us-ascii<br>
<br>
<br>
On 26/04/2015, at 1:53 am, Mike Meyer <<a href="mailto:mwm@mired.org">mwm@mired.org</a>> wrote:<br>
> My real problem is that I've got a list of points in R3 and want to decide if they determine a plane, meaning they are coplanar but not colinear. Similarly, given a list of points in R2, I want to verify that they aren't colinear. Both of these can be done by converting the list of points to a matrix and finding the rank of the matrix, but I only use the rank function in the definitions of colinear and coplanar.<br>
<br>
To compute the rank of a matrix,<br>
perform elementary row operations<br>
until the matrix is left in echelon form;<br>
the number of nonzero rows remaining in<br>
the reduced matrix is the rank.<br>
<br>
(<a href="http://www.cliffsnotes.com/math/algebra/linear-algebra/real-euclidean-vector-spaces/the-rank-of-a-matrix" target="_blank">http://www.cliffsnotes.com/math/algebra/linear-algebra/real-euclidean-vector-spaces/the-rank-of-a-matrix</a>)<br>
<br>
A matrix is in row echelon form when it<br>
satisfies the following conditions:<br>
* The first non-zero element in each row,<br>
called the leading entry, is 1<br>
* Each leading entry is in a column to<br>
the right of the leading entry in the<br>
previous row<br>
* Rows with all zero elements, if any,<br>
are below rows having a non-zero element.<br>
<br>
(<a href="http://stattrek.com/matrix-algebra/echelon-transform.aspx" target="_blank">http://stattrek.com/matrix-algebra/echelon-transform.aspx</a>)<br>
Row echelon forms aren't unique, but for determining<br>
the rank of a matrix, that doesn't matter.<br>
<br>
Code working on a list of points left as an exercise for<br>
the reader.<br>
<br>
<br>
<br>
------------------------------<br>
<br>
Message: 2<br>
Date: Tue, 28 Apr 2015 21:36:52 -0400<br>
From: Doug McIlroy <<a href="mailto:doug@cs.dartmouth.edu">doug@cs.dartmouth.edu</a>><br>
To: <a href="mailto:haskell-cafe@haskell.org">haskell-cafe@haskell.org</a><br>
Subject: Re: [Haskell-cafe] Prime sieve and Haskell demo<br>
Message-ID: <<a href="mailto:201504290136.t3T1aqI1020799@coolidge.cs.dartmouth.edu">201504290136.t3T1aqI1020799@coolidge.cs.dartmouth.edu</a>><br>
Content-Type: text/plain; charset=us-ascii<br>
<br>
With deep apologies for sending the wrong file, I try again.<br>
<br>
Doug<br>
<br>
>> How about simply changing `sieve` to `trialDiv`? It's not that I<br>
>> don't like the given example, because it gives a very small use case<br>
>> for laziness that is difficult enough to reproduce in an eagerly<br>
>> evaluated language.<br>
><br>
> Is it really so difficult to reproduce in a strict language? Here is<br>
> that Haskell example in OCaml<br>
><br>
> let primes =<br>
> let rec trialDiv (Cons (p,xs)) =<br>
> Cons (p, lazy (trialDiv @@ filter (fun x -> x mod p <> 0) @@ Lazy.force xs))<br>
> in trialDiv @@ iota 2<br>
<br>
I'm afraid I don't understand why the program isn't a sieve. Is<br>
the concern that the sequence of integers is thinned by dropping<br>
composites rather than by merely marking them and counting across<br>
them? Or is it that a trace of lazy evaluation will show that all<br>
the divisibility tests on a single integer are clustered together<br>
in time? Or something I haven't thought of?<br>
<br>
Of course the program can be written in any Turing-complete language,<br>
but the effort is likely to cause beads of sweat, like "lazy",<br>
"force", or "spawn" to be shed on the algorithmic pearl. The sieve<br>
can even be written succinctly as a bash shell script (below),<br>
which exhibits warts (e.g. five flavors of parentheses) but no sweat.<br>
<br>
Though both the Ocaml and the shell code are compact, neither dulls<br>
the luster that lazy evaluation imparts to the Haskell.<br>
<br>
sift() {<br>
while true; do<br>
read p<br>
if (( $p % $1 != 0 )); then echo $p; fi<br>
done }<br>
<br>
sink() { read p; echo $p; sift $p | sink }<br>
<br>
seq 2 1000000 | sink<br>
<br>
<br>
<br>
------------------------------<br>
<br>
Message: 3<br>
Date: Wed, 29 Apr 2015 09:42:03 +0700<br>
From: Kim-Ee Yeoh <<a href="mailto:ky3@atamo.com">ky3@atamo.com</a>><br>
To: Doug McIlroy <<a href="mailto:doug@cs.dartmouth.edu">doug@cs.dartmouth.edu</a>><br>
Cc: Haskell Cafe <<a href="mailto:haskell-cafe@haskell.org">haskell-cafe@haskell.org</a>><br>
Subject: Re: [Haskell-cafe] Prime sieve and Haskell demo<br>
Message-ID:<br>
<CAPY+ZdQsu4iotcjO7wRwqsLg34jnoQ7rhHWQ=<a href="mailto:rYwYBOVBnUj4g@mail.gmail.com">rYwYBOVBnUj4g@mail.gmail.com</a>><br>
Content-Type: text/plain; charset="utf-8"<br>
<br>
On Wed, Apr 29, 2015 at 8:36 AM, Doug McIlroy <<a href="mailto:doug@cs.dartmouth.edu">doug@cs.dartmouth.edu</a>> wrote:<br>
<br>
> I'm afraid I don't understand why the program isn't a sieve. Is<br>
> the concern that the sequence of integers is thinned by dropping<br>
> composites rather than by merely marking them and counting across<br>
> them? Or is it that a trace of lazy evaluation will show that all<br>
> the divisibility tests on a single integer are clustered together<br>
> in time? Or something I haven't thought of?<br>
><br>
<br>
When I reread Ertugrul's original email, I see that he's alerting to the<br>
danger of derision. There will be people who will mock Haskell for having<br>
an un-performant and un-Eratosthenian non-sieve on its front page.<br>
<br>
As in, Haskell people don't even know their basic math, ha ha.<br>
<br>
It used to be fibonaccis. That's too inviting of derision. Primes are more<br>
noble, so the thinking goes.<br>
<br>
That very small space on the face of Haskell must perform incredible<br>
duties. Among them, it has to showcase beautiful syntax, see:<br>
<br>
<a href="https://github.com/haskell-infra/hl/issues/46#issuecomment-72331664" target="_blank">https://github.com/haskell-infra/hl/issues/46#issuecomment-72331664</a><br>
<br>
HTH,<br>
-- Kim-Ee<br>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL: <<a href="http://mail.haskell.org/pipermail/haskell-cafe/attachments/20150429/7bf2d4e8/attachment-0001.html" target="_blank">http://mail.haskell.org/pipermail/haskell-cafe/attachments/20150429/7bf2d4e8/attachment-0001.html</a>><br>
<br>
------------------------------<br>
<br>
Message: 4<br>
Date: Wed, 29 Apr 2015 09:07:36 +0300<br>
From: fr33domlover <<a href="mailto:fr33domlover@riseup.net">fr33domlover@riseup.net</a>><br>
To: "Haskell-Cafe" <<a href="mailto:haskell-cafe@haskell.org">haskell-cafe@haskell.org</a>><br>
Subject: [Haskell-cafe] Wiki user<br>
Message-ID: <<a href="mailto:mailman.8.1430308802.9745.haskell-cafe@haskell.org">mailman.8.1430308802.9745.haskell-cafe@haskell.org</a>><br>
Content-Type: text/plain; charset=US-ASCII<br>
<br>
Hello,<br>
<br>
The Haskell Wiki says automatic registration has been disabled, and that I<br>
should send an e-mail. Could you please create a wiki account for me? The<br>
username I'd like to have is: akrasner.<br>
<br>
Thanks in advance!<br>
<br>
<br>
------------------------------<br>
<br>
Message: 5<br>
Date: Wed, 29 Apr 2015 11:21:48 +0200<br>
From: "Henk-Jan van Tuyl" <<a href="mailto:hjgtuyl@chello.nl">hjgtuyl@chello.nl</a>><br>
To: Haskell-Cafe <<a href="mailto:haskell-cafe@haskell.org">haskell-cafe@haskell.org</a>>, fr33domlover<br>
<<a href="mailto:fr33domlover@riseup.net">fr33domlover@riseup.net</a>><br>
Subject: Re: [Haskell-cafe] Wiki user<br>
Message-ID: <op.xxukara8pz0j5l@alquantor><br>
Content-Type: text/plain; charset=iso-8859-15; format=flowed;<br>
delsp=yes<br>
<br>
On Wed, 29 Apr 2015 08:07:36 +0200, fr33domlover <<a href="mailto:fr33domlover@riseup.net">fr33domlover@riseup.net</a>><br>
wrote:<br>
<br>
> should send an e-mail. Could you please create a wiki account for me? The<br>
> username I'd like to have is: akrasner.<br>
<br>
Done.<br>
<br>
Regards,<br>
Henk-Jan van Tuyl<br>
<br>
<br>
--<br>
Folding@home<br>
What if you could share your unused computer power to help find a cure? In<br>
just 5 minutes you can join the world's biggest networked computer and get<br>
us closer sooner. Watch the video.<br>
<a href="http://folding.stanford.edu/" target="_blank">http://folding.stanford.edu/</a><br>
<br>
<br>
<a href="http://Van.Tuyl.eu/" target="_blank">http://Van.Tuyl.eu/</a><br>
<a href="http://members.chello.nl/hjgtuyl/tourdemonad.html" target="_blank">http://members.chello.nl/hjgtuyl/tourdemonad.html</a><br>
Haskell programming<br>
--<br>
<br>
<br>
------------------------------<br>
<br>
Message: 6<br>
Date: Wed, 29 Apr 2015 14:25:02 +0300<br>
From: fr33domlover <<a href="mailto:fr33domlover@riseup.net">fr33domlover@riseup.net</a>><br>
To: "Henk-Jan van Tuyl" <<a href="mailto:hjgtuyl@chello.nl">hjgtuyl@chello.nl</a>><br>
Cc: Haskell-Cafe <<a href="mailto:haskell-cafe@haskell.org">haskell-cafe@haskell.org</a>><br>
Subject: Re: [Haskell-cafe] Wiki user<br>
Message-ID: <<a href="mailto:mailman.9.1430308802.9745.haskell-cafe@haskell.org">mailman.9.1430308802.9745.haskell-cafe@haskell.org</a>><br>
Content-Type: text/plain; charset=US-ASCII<br>
<br>
Thank you very much!<br>
<br>
<br>
On Wed, 29 Apr 2015 11:21:48 +0200<br>
"Henk-Jan van Tuyl" <<a href="mailto:hjgtuyl@chello.nl">hjgtuyl@chello.nl</a>> wrote:<br>
<br>
> On Wed, 29 Apr 2015 08:07:36 +0200, fr33domlover <<a href="mailto:fr33domlover@riseup.net">fr33domlover@riseup.net</a>><br>
> wrote:<br>
><br>
> > should send an e-mail. Could you please create a wiki account for me? The<br>
> > username I'd like to have is: akrasner.<br>
><br>
> Done.<br>
><br>
> Regards,<br>
> Henk-Jan van Tuyl<br>
><br>
><br>
<br>
<br>
<br>
------------------------------<br>
<br>
Message: 7<br>
Date: Wed, 29 Apr 2015 07:43:45 -0400<br>
From: Richard Eisenberg <<a href="mailto:eir@cis.upenn.edu">eir@cis.upenn.edu</a>><br>
To: "Nicholls, Mark" <<a href="mailto:nicholls.mark@vimn.com">nicholls.mark@vimn.com</a>><br>
Cc: "<a href="mailto:haskell-cafe@haskell.org">haskell-cafe@haskell.org</a>" <<a href="mailto:haskell-cafe@haskell.org">haskell-cafe@haskell.org</a>><br>
Subject: Re: [Haskell-cafe] dependent types, singleton types....<br>
Message-ID: <<a href="mailto:6CF4D7D9-76A1-4B2A-9ABE-3409739FFD56@cis.upenn.edu">6CF4D7D9-76A1-4B2A-9ABE-3409739FFD56@cis.upenn.edu</a>><br>
Content-Type: text/plain; charset="windows-1252"<br>
<br>
Hello Mark,<br>
<br>
Your suspicion that your singleton tree type is wrong is well-founded.<br>
<br>
The problem is that, in my opinion, that exercise is mentioned too early in the tutorial. To properly implement a singleton type for a parameterized type, like a binary tree, you will need `data family Sing (a :: k)`, as explained just a little bit further down in the post. You'll need to rewrite your definition for singleton numbers and booleans to work with `Sing` as well.<br>
<br>
Your code except the definition for SBranch is all correct. The problem with your definition is that you don't get the right information when pattern-matching. For example, say you have x with type `SBTree a`. If you successfully pattern match against `SBranch SZ SLeaf SLeaf`, you would want to learn `a ~ Branch Z Leaf Leaf`. But that's not what you'll get in your implementation: you'll get a type error saying that we don't know that `a0` is an `SNat`, where `a ~ Branch a0 Leaf Leaf`, or something like that. The type-level information is simply encoded in the wrong place for this to work out.<br>
<br>
Write back and I'll give you the full answer if this isn't enough to get you moving in the right direction!<br>
<br>
Richard<br>
<br>
On Apr 28, 2015, at 10:45 AM, "Nicholls, Mark" <<a href="mailto:nicholls.mark@vimn.com">nicholls.mark@vimn.com</a>> wrote:<br>
<br>
> Can someone check my answer (no I?m not doing an assessment?I?m actually learning stuff out of interest!)<br>
><br>
> working through<br>
><br>
> <a href="https://www.fpcomplete.com/user/konn/prove-your-haskell-for-great-safety/dependent-types-in-haskell" target="_blank">https://www.fpcomplete.com/user/konn/prove-your-haskell-for-great-safety/dependent-types-in-haskell</a><br>
><br>
> still there is a section about singleton types and the exercise is<br>
><br>
> ?Exercise: Define the binary tree type and implement its singleton type.?<br>
><br>
> Ok, I think I?m probably wrong?.a binary tree is something like?<br>
><br>
> > data BTree a = Leaf | Branch a (BTree a) (BTree a)<br>
><br>
> With DataKind<br>
><br>
> My logic goes?<br>
> Leaf is an uninhabited type, so I need a value isomorphic to it?.<br>
><br>
> Easy?<br>
><br>
> > data SBTree a where<br>
> > SLeaf :: SBTree Leaf<br>
><br>
> Things like<br>
> Branch Integer Leaf (Branch String Leaf Leaf)<br>
> Are uninhabited?so I need to add<br>
><br>
> > SBranch :: (a :: *) -> (SBTree (b :: BTree *)) -> (SBTree (c :: BTree *)) -> SBTree (Branch a b c)<br>
><br>
> ?<br>
><br>
> It compiles?but?.is it actually correct?<br>
> Things like<br>
><br>
> > y = SBranch (SS (SS SZ)) SLeaf SLeaf<br>
> > z = SBranch (SS (SS SZ)) (SBranch SZ SLeaf SLeaf) SLeaf<br>
><br>
> Seem to make sense ish.<br>
><br>
> From: Nicholls, Mark<br>
> Sent: 28 April 2015 9:33 AM<br>
> To: Nicholls, Mark<br>
> Subject: sds<br>
><br>
> Hello,<br>
><br>
> working through<br>
><br>
> <a href="https://www.fpcomplete.com/user/konn/prove-your-haskell-for-great-safety/dependent-types-in-haskell" target="_blank">https://www.fpcomplete.com/user/konn/prove-your-haskell-for-great-safety/dependent-types-in-haskell</a><br>
><br>
> but a bit stuck...with an error...<br>
><br>
> > {-# LANGUAGE DataKinds, TypeFamilies, TypeOperators, UndecidableInstances, GADTs, StandaloneDeriving #-}<br>
><br>
> > data Nat = Z | S Nat<br>
><br>
> > data Vector a n where<br>
> > Nil :: Vector a Z<br>
> > (:-) :: a -> Vector a n -> Vector a (S n)<br>
> > infixr 5 :-<br>
><br>
> I assume init...is a bit like tail but take n - 1 elements from the front....but...<br>
><br>
> > init' :: Vector a ('S n) -> Vector a n<br>
> > init' (x :- Nil) = Nil<br>
> > init' (x :- xs@(_ :- _)) = x :- (init' xs)<br>
><br>
> > zipWithSame :: (a -> b -> c) -> Vector a n -> Vector b n -> Vector c n<br>
> > zipWithSame f Nil Nil = Nil<br>
> > zipWithSame f (x :- xs) (y :- xs@(_ :- _)) = Nil<br>
><br>
> Mark Nicholls | Senior Technical Director, Programmes & Development - Viacom International Media Networks<br>
> A: 17-29 Hawley Crescent London NW1 8TT | e: <a href="mailto:Nicholls.Mark@vimn.com">Nicholls.Mark@vimn.com</a> T: <a href="tel:%2B44%20%280%29203%20580%202223" value="+442035802223">+44 (0)203 580 2223</a><br>
><br>
> <image001.png><br>
><br>
><br>
><br>
> CONFIDENTIALITY NOTICE<br>
><br>
> This e-mail (and any attached files) is confidential and protected by copyright (and other intellectual property rights). If you are not the intended recipient please e-mail the sender and then delete the email and any attached files immediately. Any further use or dissemination is prohibited.<br>
><br>
> While MTV Networks Europe has taken steps to ensure that this email and any attachments are virus free, it is your responsibility to ensure that this message and any attachments are virus free and do not affect your systems / data.<br>
><br>
> Communicating by email is not 100% secure and carries risks such as delay, data corruption, non-delivery, wrongful interception and unauthorised amendment. If you communicate with us by e-mail, you acknowledge and assume these risks, and you agree to take appropriate measures to minimise these risks when e-mailing us.<br>
><br>
> MTV Networks International, MTV Networks UK & Ireland, Greenhouse, Nickelodeon Viacom Consumer Products, VBSi, Viacom Brand Solutions International, Be Viacom, Viacom International Media Networks and VIMN and Comedy Central are all trading names of MTV Networks Europe. MTV Networks Europe is a partnership between MTV Networks Europe Inc. and Viacom Networks Europe Inc. Address for service in Great Britain is 17-29 Hawley Crescent, London, NW1 8TT.<br>
><br>
> _______________________________________________<br>
> Haskell-Cafe mailing list<br>
> <a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
> <a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br>
<br>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL: <<a href="http://mail.haskell.org/pipermail/haskell-cafe/attachments/20150429/5cfd0d5d/attachment-0001.html" target="_blank">http://mail.haskell.org/pipermail/haskell-cafe/attachments/20150429/5cfd0d5d/attachment-0001.html</a>><br>
<br>
------------------------------<br>
<br>
Subject: Digest Footer<br>
<br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br>
<br>
<br>
------------------------------<br>
<br>
End of Haskell-Cafe Digest, Vol 140, Issue 52<br>
*********************************************<br>
</blockquote></div>