Re: [Haskell-cafe] [extension]syntactic sugar for maps

2013-03-27 Thread Eric Rasmussen
I agree that fromList or pattern matching at the function or case level are readable. We probably don't need new sugar. For what it's worth, in scala you can use "->" to construct tuples, so you'll sometimes see maps created like this: Map(1 -> "one", 2 -> "two", 3 -> "foo") You can always do som

[Haskell-cafe] catching IO errors in a monad transformer stack

2013-07-18 Thread Eric Rasmussen
Hello, I am writing a small application that uses a monad transformer stack, and I'm looking for advice on the best way to handle IO errors. Ideally I'd like to be able to perform an action (such as readFile "file_that_does_not_exist"), catch the IOError, and then convert it to a string error in M

Re: [Haskell-cafe] catching IO errors in a monad transformer stack

2013-07-18 Thread Eric Rasmussen
pattern may be the MonadCatchIO class: > > http://hackage.haskell.org/package/MonadCatchIO-transformers > > > 2013/7/18 Eric Rasmussen > >> Hello, >> >> I am writing a small application that uses a monad transformer stack, and >> I'm looking for advice on

Re: [Haskell-cafe] List Monads and non-determinism

2013-07-20 Thread Eric Rasmussen
For the sake of approaching this in yet another way, it can also be helpful to substitute the definitions of bind and return in your expression. If we start with the definitions: instance Monad [] where xs >>= f = concat (map f xs) return x = [x] Then we can make the following transformations

Re: [Haskell-cafe] catching IO errors in a monad transformer stack

2013-07-21 Thread Eric Rasmussen
IOException in an arbitrary monad. Do you happen to know of another approach for catching IOExceptions and throwing them in ErrorT? Thanks, Eric On Sun, Jul 21, 2013 at 7:00 AM, Arie Peterson wrote: > On Thursday 18 July 2013 23:05:33 Eric Rasmussen wrote: > > […] > > Would there

Re: [Haskell-cafe] catching IO errors in a monad transformer stack

2013-07-22 Thread Eric Rasmussen
e) > => m a -> (e -> m a) -> m a > > I'd recommend you use that instead of MonadCatchIO. > > > On Mon, Jul 22, 2013 at 4:13 AM, Eric Rasmussen > wrote: > >> Arie, >> >> Thanks for calling that out. The most useful part for my case

Re: [Haskell-cafe] function arithmetic?

2013-08-31 Thread Eric Rasmussen
Might not be exactly what you're looking for, but Control.Arrow has a rich set of operators that can be used to combine functions. For instance, there's an example on http://en.wikibooks.org/wiki/Haskell/Understanding_arrows showing an addA function that can be used to apply two functions to the s

Re: [Haskell-cafe] Looking for numbers to support using haskell

2013-09-23 Thread Eric Rasmussen
Hi Nick, FP Complete has a lot of good resources on this topic, including some case studies: https://www.fpcomplete.com/business/resources/case-studies/ I believe part of their aim is making the business case for Haskell (meaning many of the resources are geared towards management), which I reali

Re: [Haskell-cafe] Please critique my code (a simple lexer)

2012-05-22 Thread Eric Rasmussen
Another suggestion is to use pattern matching at the function level: doLex' lexer loc [] = [makeToken EOF] doLex' lexer loc (x:xs) = case x of ' ' -> more (locInc loc 1) xs '\n'-> more (locNL loc) xs ... _ -> That saves you from having to deconstruct repeatedly in you

Re: [Haskell-cafe] A functional programming solution for Mr and Mrs Hollingberry

2012-05-29 Thread Eric Rasmussen
I added a Scala solution since Haskell is already well represented. Regarding exercises that are easier in OO, I don't think you'll find one that a good Haskell programmer can't match in a functional style. But if you make simulation the goal of the exercise (rather than writing a program that tak

Re: [Haskell-cafe] Am I the only one having problems with RWH?

2012-10-06 Thread Eric Rasmussen
I found I had to keep switching between RWH and other books for these concepts to sink in. A really good resource that I don't see mentioned too often is the Haskell wikibook: http://en.wikibooks.org/wiki/Haskell I don't remember it covering parsec specifically but if you get grounded in all the

Re: [Haskell-cafe] Teaching Haskell @ MOOCs like Coursera or Udacity

2012-10-24 Thread Eric Rasmussen
I can see that the required effort would be prohibitive, but after thinking about this some more I do think there are a couple of nice advantages: 1) Quizzes and graded assignments offer some structure to self study, and having some form of feedback/validation when you first get started is helpful

Re: [Haskell-cafe] Object Oriented programming for Functional Programmers

2012-12-30 Thread Eric Rasmussen
Since no one's mentioned it yet, you might consider learning Scala. A good starting point is http://www.artima.com/pins1ed/index.html (note that the free edition is outdated but still a good introduction). Scala has a mix of functional and OO programming styles, though (having come first from Hask

Re: [Haskell-cafe] Good reads?

2011-04-26 Thread Eric Rasmussen
rough code on Hackage and reading up on different approaches, I can't seem to find a consensus in Haskell. If anyone knows of a book/resource that breaks down different approaches to common problems and when/why you might choose one over the other, I'm very interested. -Eric Rasmussen

Re: [Haskell-cafe] Comparison of common Haskell libraries (Was: Good reads?)

2011-04-27 Thread Eric Rasmussen
Thank you -- I will try your spreadsheet package for sure, and when I have more expertise in this area I'd be happy to contribute to the wiki. On Wed, Apr 27, 2011 at 3:00 AM, Henning Thielemann < schlepp...@henning-thielemann.de> wrote: > Eric Rasmussen schrieb: > > >

Re: [Haskell-cafe] Server hosting

2011-05-06 Thread Eric Rasmussen
Has anyone tried webfaction.com with Haskell? I use them for custom Python web apps and they're great (competitive shared hosting price, ssh access, easy to setup proxy apps listening on custom ports or cgi apps with the ability to edit .htaccess). Loosely speaking it's a cross between traditional

Re: [Haskell-cafe] ANN: timeplot-0.3.0 - the analyst's swiss army knife for visualizing ad-hoc log files

2011-05-06 Thread Eric Rasmussen
Hi Eugene, This is a great tool. I often have to analyze data from multiple sources, so I usually create a SQLite database to store it all and start running queries. I just tested it in the form: $ echo 'SELECT...' | sqlite3 database.db | tplot And for more complicated queries outputting the re

[Haskell-cafe] parsing currency amounts with parsec

2011-05-09 Thread Eric Rasmussen
Hi everyone, I am relatively new to Haskell and Parsec, and I couldn't find any articles on parsing numbers in the following format: Positive: $115.33 Negative: ($1,323.42) I'm working on the parser for practical purposes (to convert a 3rd-party generated, most unhelpful format into one I can us

Re: [Haskell-cafe] parsing currency amounts with parsec

2011-05-09 Thread Eric Rasmussen
try float <|> double On Mon, May 9, 2011 at 8:15 PM, wren ng thornton wrote: > On 5/9/11 10:04 PM, Antoine Latter wrote: > >> On Mon, May 9, 2011 at 5:07 PM, Eric Rasmussen >> wrote: >> >>> Hi everyone, >>> >>

Re: [Haskell-cafe] parsing currency amounts with parsec

2011-05-11 Thread Eric Rasmussen
Very helpful -- thanks everyone! The handling of currency amounts in hledger is what I was looking for in terms of alternate ways to parse and represent dollar amounts in Haskell. On Wed, May 11, 2011 at 6:05 PM, Simon Michael wrote: > On 5/10/11 2:52 PM, Roman Cheplyaka wrote: > >> You could re

Re: [Haskell-cafe] The Lisp Curse

2011-05-19 Thread Eric Rasmussen
I only recently started learning Haskell and have had a difficult time convincing other Python hackers to come on board. I see two things that might help: 1) A resource to make informed decisions about different libraries. Something that includes specific criteria like how long a library has been

Re: [Haskell-cafe] The Lisp Curse

2011-05-23 Thread Eric Rasmussen
In terms of making the interface more friendly to beginners, I wonder if this is partially an issue of how to search and how to format the results. I just searched several places for "xml rpc" and found: Hackage: the first few links from the google search are different versions of haxr Hayoo: 0 pa

[Haskell-cafe] representing spreadsheets

2011-05-27 Thread Eric Rasmussen
Hi everyone, I'm hoping someone can point me in the right direction for a project I'm working on. Essentially I would like to represent a grid of data (much like a spreadsheet) in pure code. In this sense, one would need functions to operate on the concepts of "rows" and "columns". A simple "cell"

Re: [Haskell-cafe] representing spreadsheets

2011-05-27 Thread Eric Rasmussen
hese requirements. On Fri, May 27, 2011 at 12:33 PM, Tillmann Rendel < ren...@informatik.uni-marburg.de> wrote: > Hi, > > > Eric Rasmussen wrote: > >> The spreadsheet analogy isn't too literal as I'll be using this for data >> with a more regular structur

Re: [Haskell-cafe] representing spreadsheets

2011-05-27 Thread Eric Rasmussen
Thanks! I think GADTs may work nicely for this project, so I'm going to start building it out. On Fri, May 27, 2011 at 4:16 PM, Alexander Solla wrote: > On Fri, May 27, 2011 at 3:11 PM, Eric Rasmussen > wrote: > >> Stephen, thanks for the link! The paper was an

Re: [Haskell-cafe] haskellwiki slow/unresponsive

2011-06-03 Thread Eric Rasmussen
This is a bit of a tangent, but has anyone developed wiki software in Haskell? If anyone is working on this or interested in working on it, I'd like to help. I've built simple wiki applications with Python web frameworks and have been looking for a good project to start learning one of the Haskell

Re: [Haskell-cafe] haskellwiki slow/unresponsive

2011-06-03 Thread Eric Rasmussen
applications on top of that framework. I'm still relatively new to the Haskell community so I apologize if much of this has been addressed before! On Fri, Jun 3, 2011 at 3:11 PM, Gwern Branwen wrote: > On Fri, Jun 3, 2011 at 4:17 PM, Eric Rasmussen > wrote: > > This is a bit o

Re: [Haskell-cafe] Generating simple histograms in png format?

2011-06-12 Thread Eric Rasmussen
There is a program written in Haskell called Timeplot that does this: http://www.haskell.org/haskellwiki/Timeplot It's an executable rather than a library, but you can use your own Haskell code to preprocess/format data and pipe it to the program to generate histograms as pngs. Best, Eric On Su

Re: [Haskell-cafe] Iteratee IO examples

2011-06-24 Thread Eric Rasmussen
Hi, Examples are very helpful to me too -- thank you for sharing. I'm especially curious to see if there are any examples that allow you to use or convert non-iteratee-based functions. I have only just begun reading about iteratees and might be missing the point, but it seems like many of the exam

[Haskell-cafe] attoparsec and vectors

2011-06-28 Thread Eric Rasmussen
Hi everyone, I have a task that involves parsing a flat-file into a vector from the Data.Vector package. In the interest of keeping things simple, I first used Attoparsec.Text's version of "many" and then converted the resulting list to a vector: import qualified Data.Vector as V import Data.Atto

Re: [Haskell-cafe] Searching of several substrings (with Data.Text ?)

2011-07-05 Thread Eric Rasmussen
I've been looking into building parsers at runtime (from a config file), and in my case it's beneficial to fit them into the context of a larger parser with Attoparsec.Text. This code is untested for practical use so I doubt you'll see comparable performance to the aforementioned regex packages, bu

[Haskell-cafe] file splitter with enumerator package

2011-07-22 Thread Eric Rasmussen
Hi everyone, A friend of mine recently asked if I knew of a utility to split a large file (4gb in his case) into arbitrarily-sized files on Windows. Although there are a number of file-splitting utilities, the catch was it couldn't break in the middle of a line. When the standard "why don't you us

Re: [Haskell-cafe] file splitter with enumerator package

2011-07-22 Thread Eric Rasmussen
Hi Felipe, Thank you for the very detailed explanation and help. Regarding the first point, for this particular use case it's fine if the user-specified file size is extended by the length of a partial line (it's a compact csv file so if the user breaks a big file into 100mb chunks, each chunk wou

Re: [Haskell-cafe] file splitter with enumerator package

2011-07-24 Thread Eric Rasmussen
Since the program only needs to finish a line after it's made a bulk copy of a potentially large chunk of a file (could be 25 - 500 mb), I was hoping to find a way to copy the large chunk in constant memory and without inspecting the individual bytes/characters. I'm still having some difficulty wit

Re: [Haskell-cafe] file splitter with enumerator package

2011-07-25 Thread Eric Rasmussen
I just found another solution that seems to work, although I don't fully understand why. In my original function where I used EB.take to strictly read in a Lazy ByteString and then L.hPut to write it out to a handle, I now use this instead (full code in the annotation here: http://hpaste.org/49366)

Re: [Haskell-cafe] Fractional Part

2011-08-02 Thread Eric Rasmussen
Just a hint, but with Project Euler there's a chance you're headed in a difficult direction if you're working with the decimal parts directly. Usually (always?) you can approach the problem in a way that won't depend on something like decimal precision that can be different across systems/languages

Re: [Haskell-cafe] Categorized Weaknesses from the State of Haskell 2011 Survey

2011-09-13 Thread Eric Rasmussen
+1 for Heinrich Apfelmus's suggestion of cookbook recipes. In other language communities I see a lot of "quickstart" guides designed to help someone get up and running without a full understanding of what they're doing, presumably with the hope that once they get started it will provide the motiva

Re: [Haskell-cafe] Parsing binary data question

2011-09-28 Thread Eric Rasmussen
Hi Michael, I recommend Attoparsec when parsing raw data into custom data types. There aren't as many examples and tutorials as there are for Parsec, but the API is very similar, and some of the important differences are listed on Attoparsec's Hackage entry. There are also helpful examples of its