Re: [Haskell-cafe] Errors in non-monadic code
On Mon, Aug 19, 2013 at 5:24 PM, Tom Ellis tom-lists-haskell-cafe-2...@jaguarpaw.co.uk wrote: On Mon, Aug 19, 2013 at 05:15:39PM -0400, jabolo...@google.com wrote: But I would like to see more code move away from exceptions and into types like Maybe or Either or other types defined for the particular situation (as some people were suggesting in the beginning of the thread). And the reason for this it is because when you program against types you have to make a decision whether to handle the error or let it bleed through: you can't ignore the choice because you can't ignore the type. On the other hand, with exceptions, you can easily forget to handle the exception if you're not looking at the documentation at the time when you write the code. This is /exactly/ the reason to avoid exceptions where possible. Tom And tangentially related, it's why Go uses error return values (with functions being able to return multiple values), e.g. http://blog.golang.org/error-handling-and-go ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] question about indentation conventions
I prefer the other style--as do others, evidently (see the example in my first reply.) I agree that this was a good discussion, but let's not conclude so easily that the entire community is in favor of one thing or the other. On Mon, Jul 1, 2013 at 8:24 PM, Richard Cobbe co...@ccs.neu.edu wrote: On Sun, Jun 30, 2013 at 07:53:08PM -0400, Richard Cobbe wrote: Two questions: And what I've concluded by reading this thread: 1) Are there wide-spread conventions in the Haskell community for how to indent an application expression that's split across multiple lines? Well, there's general consensus in favor of indenting the continuing lines, but not a lot of consensus on how much, etc. Not surprising, and that's OK. Infix operators are more complicated. 2) If there is such a convention, how do I make Emacs's haskell-mode do it? Doesn't seem to be possible, unless you're in a do block. To be clear: I wasn't asking how to make Emacs do all of my indentation automatically, as it can in Lisp and C modes. I realize that isn't possible. But since haskell-mode doesn't have very good support for the style I personally prefer (which is, in fact, consistent with Richard O'Keefe's favorite rule), I wondered if that might indicate that the community prefers a different style. Apparently not. Thanks to all who responded; it's been an interesting (if occasionally overly excited) discussion. Richard ___ 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] question about indentation conventions
The Haskell Style Guide is quite popular: https://github.com/tibbe/haskell-style-guide/blob/master/haskell-style.md (accompying elisp module: https://github.com/tibbe/haskell-style-guide/blob/master/haskell-style.el) I am not sure what the verdict is on functions spanning multiple lines, other than 80 columns being the max line length. Personally, I do what haskell-mode + style-guide.el default to, which is to indent to the same level like you said, e.g.: fun a b c d e f Looking at some of the style guide author's code seems to suggest this is what he does too: https://github.com/tibbe/ekg/blob/master/System/Remote/Snap.hs#L155 Of course, you're free to do it whichever way you prefer--it only matters if you are collaborating with others who don't share your preferences (always a fun activity.) It would be cool if there was a The One Formatting Tool for Haskell, a la go fmt for Go, or an 'indent' without so many options that the tool is moot. On Sun, Jun 30, 2013 at 9:04 PM, Richard Cobbe co...@ccs.neu.edu wrote: On Sun, Jun 30, 2013 at 05:41:46PM -0700, Darren Grant wrote: Hi Richard, This page helped me when starting out: http://en.wikibooks.org/wiki/Haskell/Indentation On 2013-06-30 4:55 PM, Richard Cobbe co...@ccs.neu.edu wrote: snip 1) Are there wide-spread conventions in the Haskell community for how to indent an application expression that's split across multiple lines? For how to indent an expression that uses infix operators? Or does everyone pretty much do their own thing? snip Thanks for the pointer, Darren, and I did come across that page earlier. I should have been clearer in my original question: I'm curious about what to do when a multi-argument function application gets split across lines. That wiki page dicsusses how the layout rule interacts with various special forms (let, where, if, do, case), but it doesn't seem to address function applications, beyond implying that it's ok to indent the continuing lines of a function application. Richard ___ 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] how do i get cabal to reinstall dependencies with profiling enabled?
My simple way is to move ~/.ghc (or ~/.ghc and ~/.cabal) somewhere else, then make (e.g. by running cabal update) or edit ~/.cabal/config to say library profiling, executable profiling and documentation: True, then run cabal install on one of my projects. On Wed, Apr 17, 2013 at 5:13 PM, Anatoly Yakovenko aeyakove...@gmail.comwrote: ___ 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] websockets client
Yes, Jasper's websockets has a client in recent versions that works really nicely since server and client have the same APIs. The example was a little hidden: https://github.com/jaspervdj/websockets/blob/master/example/client.hs On Thu, Feb 21, 2013 at 10:09 PM, Stephen Olsen steve.ol...@gmail.comwrote: Are there any good websockets client libraries for haskell. I've been searching for one but can only come up with server implementations. ___ 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] 9.3 - (2 * 4.5) = 0.3000000000000007
Fun with floating point! # ghci GHCi, version 7.4.2: http://www.haskell.org/ghc/ :? for help Loading package ghc-prim ... linking ... done. Loading package integer-gmp ... linking ... done. Loading package base ... linking ... done. Prelude 9223372036854775807.0 == 9223372036854775808 True http://en.wikipedia.org/wiki/Floating_point#Accuracy_problems On Wed, Jan 16, 2013 at 7:25 AM, ivan dragolov i...@dragolov.net wrote: 9.3 - (2 * 4.5) = 0.3007 I expected 0.3 ? -- Иван Драголов dragolov.net GSM: 0888 63 19 46 GSM за SMS: 0878 82 83 93 facebook.com/ivan.dragolov twitter.com/dragolov ___ 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] 9.3 - (2 * 4.5) = 0.3000000000000007
This may be of interest if you want full-precision decimals: http://www.haskell.org/haskellwiki/Libraries_and_tools/Mathematics#Decimal_numbers On Wed, Jan 16, 2013 at 7:30 AM, Patrick Mylund Nielsen hask...@patrickmylund.com wrote: Fun with floating point! # ghci GHCi, version 7.4.2: http://www.haskell.org/ghc/ :? for help Loading package ghc-prim ... linking ... done. Loading package integer-gmp ... linking ... done. Loading package base ... linking ... done. Prelude 9223372036854775807.0 == 9223372036854775808 True http://en.wikipedia.org/wiki/Floating_point#Accuracy_problems On Wed, Jan 16, 2013 at 7:25 AM, ivan dragolov i...@dragolov.net wrote: 9.3 - (2 * 4.5) = 0.3007 I expected 0.3 ? -- Иван Драголов dragolov.net GSM: 0888 63 19 46 GSM за SMS: 0878 82 83 93 facebook.com/ivan.dragolov twitter.com/dragolov ___ 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] Fighting research paper bit-rot
Thanks, this had me pretty confused too. STM.check itself also differs from in earlier versions of the library where it returned () or undefined. On Fri, Dec 21, 2012 at 8:35 PM, cheater cheater cheate...@gmail.comwrote: Hi guys, after yet another episode of trying to figure out why library code doesn't make any sense when reading the related paper, I decided to start a small wiki just for the purpose of describing differences between what's in the paper and what's in the code. The first article can be found at: http://functionalpapersupdated.wikia.com/wiki/Transactional_memory_with_data_invariants This one was tricky: it was the check from stm-invariants.pdf. There is a check in the STM library which is a completely different function. The check from the paper is in another module and library and is called alwaysSucceeds. Everyone's more than welcome to add their favourite papers and describe the differences. The wiki is freely editable. Hopefully it can, with time, grow to be of help to anyone trying to learn about Haskell or category theory or functional programming in general. I can't promise a huge amount of updates on my side (I'm just a guy learning how to use Haskell, not a researcher) but hopefully this great community can make it happen :) If you're a publishing author, and you know of such updates to your papers, please consider starting a page for your paper. It's also a good place to track the implementations of ideas described in such papers, especially in case there are multiple ones or the implementation hasn't been discussed in the paper itself. ___ 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] [Security] Put haskell.org on https
PGP tends to present many usability issues, and in this case it would make more sense/provide a clearer win if there were many different, semi-untrusted hackage mirrors. Just enable HTTPS and have Cabal validate the server certificate against a CA pool of one. PKI/trusting obscure certificate authorities in Egypt and Syria is the biggest concern here, not somebody MITMing your initial Cabal installation (which in a lot of cases happens through apt-get or yum, anyway.) On Mon, Oct 29, 2012 at 12:34 AM, Changaco chang...@changaco.net wrote: On Sun, 28 Oct 2012 17:07:24 -0400 Patrick Hurst wrote: How do you get a copy of cabal while making sure that somebody hasn't MITMed you and replaced the PGP key? Ultimately it is a DNS problem. To establish a secure connection with haskell.org you'd have to get the certificate from the DNS, but that technology is not ready yet, so all you can do is check the key against as many sources as possible like Michael Walker said. On Sun, 28 Oct 2012 17:46:06 -0400 Patrick Hurst wrote: So why not use HTTPS? Because it doesn't solve the problem. ___ 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] [Security] Put haskell.org on https
Of course, as long as Cabal itself is distributed through this same https-enabled site, you have the same PKI-backed security as just about any major website. This model has problems, yes, but it's good enough, and it's easy to use. If you really want to improve it (without impacting usability), have Google/the browser vendors pin the public cert for haskell.org. On Mon, Oct 29, 2012 at 12:45 AM, Patrick Mylund Nielsen hask...@patrickmylund.com wrote: PGP tends to present many usability issues, and in this case it would make more sense/provide a clearer win if there were many different, semi-untrusted hackage mirrors. Just enable HTTPS and have Cabal validate the server certificate against a CA pool of one. PKI/trusting obscure certificate authorities in Egypt and Syria is the biggest concern here, not somebody MITMing your initial Cabal installation (which in a lot of cases happens through apt-get or yum, anyway.) On Mon, Oct 29, 2012 at 12:34 AM, Changaco chang...@changaco.net wrote: On Sun, 28 Oct 2012 17:07:24 -0400 Patrick Hurst wrote: How do you get a copy of cabal while making sure that somebody hasn't MITMed you and replaced the PGP key? Ultimately it is a DNS problem. To establish a secure connection with haskell.org you'd have to get the certificate from the DNS, but that technology is not ready yet, so all you can do is check the key against as many sources as possible like Michael Walker said. On Sun, 28 Oct 2012 17:46:06 -0400 Patrick Hurst wrote: So why not use HTTPS? Because it doesn't solve the problem. ___ 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] [Security] Put haskell.org on https
Sure. No matter what's done in Cabal, the clients for everything else will still be mainly browsers. On Mon, Oct 29, 2012 at 12:59 AM, Niklas Hambüchen m...@nh2.me wrote: No matter what we do with cabal, it would be great if I could soon point my browser at https://haskell.org *anyway*. On 28/10/12 23:55, Patrick Mylund Nielsen wrote: Of course, as long as Cabal itself is distributed through this same https-enabled site, you have the same PKI-backed security as just about any major website. This model has problems, yes, but it's good enough, and it's easy to use. If you really want to improve it (without impacting usability), have Google/the browser vendors pin the public cert for haskell.org http://haskell.org. On Mon, Oct 29, 2012 at 12:45 AM, Patrick Mylund Nielsen hask...@patrickmylund.com mailto:hask...@patrickmylund.com wrote: PGP tends to present many usability issues, and in this case it would make more sense/provide a clearer win if there were many different, semi-untrusted hackage mirrors. Just enable HTTPS and have Cabal validate the server certificate against a CA pool of one. PKI/trusting obscure certificate authorities in Egypt and Syria is the biggest concern here, not somebody MITMing your initial Cabal installation (which in a lot of cases happens through apt-get or yum, anyway.) On Mon, Oct 29, 2012 at 12:34 AM, Changaco chang...@changaco.net mailto:chang...@changaco.net wrote: On Sun, 28 Oct 2012 17:07:24 -0400 Patrick Hurst wrote: How do you get a copy of cabal while making sure that somebody hasn't MITMed you and replaced the PGP key? Ultimately it is a DNS problem. To establish a secure connection with haskell.org http://haskell.org you'd have to get the certificate from the DNS, but that technology is not ready yet, so all you can do is check the key against as many sources as possible like Michael Walker said. On Sun, 28 Oct 2012 17:46:06 -0400 Patrick Hurst wrote: So why not use HTTPS? Because it doesn't solve the problem. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org mailto: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
Re: [Haskell-cafe] Am I the only one having problems with RWH?
I'm not totally sure if you're having problems with RWH, or think it's too easy, but here are my thoughts on both: Both RWH and LYAH (http://learnyouahaskell.com/) are intended for beginners/people who just want to get started, and RWH tends to be regarded as the hardest to understand (read LYAH then RWH.) (RWH is also specifically aimed at demonstrating how to solve practical problems, not hard/academical ones.) I too agree that LYAH is the easier one, and it is slightly more focused on the theory and concepts of Haskell, so I would definitely recommend checking that out. I found that the topics and chapters of the two books mix nicely--you don't get the feeling that you're just reading the same book twice. For other Haskell-related writings, Simon Marlow is currently writing a book based on his Parallel and Concurrent Programming in Haskell tutorial (http://community.haskell.org/~simonmar/par-tutorial.pdf) for O'Reilly at the moment. In the meantime, I've found the Simons' papers to be interesting reading: http://research.microsoft.com/en-us/people/simonpj/ http://research.microsoft.com/en-us/people/simonmar/ The level of the papers range from LYAH-style material to the more abstract/advanced a la Philip Wadler's Theorems For Free (http://ttic.uchicago.edu/~dreyer/course/papers/wadler.pdf) Most of Philip Wadler's papers are also very interesting: http://homepages.inf.ed.ac.uk/wadler/ So, you're probably at a level where you'll want to start looking for interesting academical papers on Haskell/FP and theory, then re-visit RWH once in a while. I found the papers on STM, Cloud Haskell, and Parallel Haskell, to be the most interesting, easy to understand, and practically useful. On Sat, Oct 6, 2012 at 1:41 PM, Janek S. fremenz...@poczta.onet.pl wrote: I began learning Haskell 9 months ago. I still consider myself a beginner, but I'm progressing towards more advanced concepts. I read scientific papers (simpler ones) and books about Haskell and functional programming. Right now I'm reading Pearls of Functional Algorithm Design, Introduction to Functional Programming, Implementation of Functional Programming Languages and Real World Haskell. RWH is causing me a lot of trouble though. This leads me to frustration because book covers rather basic material. I just spent another 1,5 hour reading chapter 10 again and trying to understand how presented parsing functions work. Even if I am barely able to grasp what is going on I feel that I wouldn't know how to write such code by myself. Am I the only one having such problems with RWH? Jan ___ 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] a parallel mapM?
Check out the parallel combinators in parallel-io: http://hackage.haskell.org/packages/archive/parallel-io/0.3.2/doc/html/Control-Concurrent-ParallelIO-Global.html On Fri, Sep 28, 2012 at 1:01 PM, Greg Fitzgerald gari...@gmail.com wrote: I'm new to concurrent programming in Haskell. I'm looking for a drop-in replacement for 'mapM' to parallelize a set of independent IO operations. I hoped 'mapConcurrently' might be it, but I need something that will only spawn as many threads as I have CPUs available [1]. I also tried Control.Parallel.Strategies [2]. While that route works, I had to use unsafePerformIO. Considering that IO is for sequencing effects and my IO operation doesn't cause any side-effects (besides hogging a file handle), is this a proper use of unsafePerformIO? Attempt 1 -- import System.Process(readProcess) import Control.Concurrent.Async(mapConcurrently) main :: IO [String] main = mapConcurrently (\n - readProcess echo [test: ++ show n] ) [0..1000] $ ghc --version The Glorious Glasgow Haskell Compilation System, version 7.6.1 $ runghc test.hs test.hs: runInteractiveProcess: pipe: Too many open files test.hs: runInteractiveProcess: pipe: Too many open files test.hs: runInteractiveProcess: pipe: Too many open files test.hs: runInteractiveProcess: pipe: Too many open files test.hs: runInteractiveProcess: pipe: Too many open files test.hs: runInteractiveProcess: pipe: Too many open files test.hs: runInteractiveProcess: pipe: Too many open files test.hs: runInteractiveProcess: pipe: Too many open files test.hs: runInteractiveProcess: pipe: Too many open files test.hs: echo: createProcess: resource exhausted (Too many open files) Attempt 2 -- import System.Process(readProcess) import Control.Parallel.Strategies(parMap, rpar) import System.IO.Unsafe(unsafePerformIO) main :: IO [String] main = myMapConcurrently (\n - readProcess echo [test: ++ show n] ) [0..1000] where myMapConcurrently f = return . parMap rpar (unsafePerformIO . f) $ runghc test.hs /dev/null echo Success Success Thanks, Greg ___ 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