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
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
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
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
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
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
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
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
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
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
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
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
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
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
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:
>
> >
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
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
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
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,
>>>
>>
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
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
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
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"
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
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
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
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
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
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
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
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
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
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
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
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)
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
+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
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
38 matches
Mail list logo