In writing library functions, what is the best way these days to let users handle errors how they want to? In times past you could simply use the much hated (for good reason) fail function and then the user could simply instantiate with the monad they wanted for the kind of error handling they required (e.g. if they didn't need to know why something failed they could use Maybe, they could use Either if they wanted the message or even IO if they wanted a crash).
But since the fail definition has been removed from the Either monad definition, this strategy doesn't work anymore. What is the correct way to do this now? Everything I've read seems to explain how to explicitly use different kinds of errors (e.g. EitherT, MaybeT and so on) but that's exactly what I don't want to do.submitted by haskellUser
[link] [20 comments]
I'm sure I'm not the only person who's noticed that discussions about the stack build tool seem to have permeated just about any discussion on this subreddit with even a tangential relation to package management or tooling. Personally, I love stack, and am happy to discuss it with others quite a bit.
That said, I think it's quite unhealthy for our community for many important topics to end up getting dwarfed in rehash of the same stack discussion/debate/flame war that we've seen so many times. The most recent example was stealing the focus from Duncan's important cabal talk, for a discussion that really is completely unrelated to what he was saying.
Here's my proposal: let's get it all out in this thread. If people bring up the stack topic in an unrelated context elsewhere, let's point them back to this thread. If we need to start a new thread in a few months (or even a few weeks) to "restart" the discussion, so be it.
And if we can try to avoid ad hominems and sensationalism in this thread, all the better.
Finally, just to clarify my point here: I'm not trying to stop new threads from appearing that mention stack directly (e.g., ghc-mod adding stack support). What I'm asking is that:
- Threads that really aren't about stack don't bring up "the stack debate"
- Threads that are about stack try to discuss new things, not discuss the exact same thing all over again (no point polluting that ghc-mod thread with a stack vs cabal debate, it's been done already)
[link] [281 comments]
There was recently a post, [Haskell-cafe] GSoC Retrospective; so I ask, "GSoC participants, how was your experience and what would you like to tell us about your results?"submitted by rpglover64
[link] [6 comments]
Because of the reccomendations of bitemyapp github page I tried to learn haskell by the Craft book.
The explanation was fine the only thing that makes my grazy was that a lot of exercises were written on a way that was not clear what was the meaning of the exercise.
Now I wonder.
Is there a book with a lot of exercises where I can learn Haskell.
I have looked at LYAH but there no exercises.
Roelofsubmitted by roelofwobben
[link] [18 comments]
Guido van Rossum reminisces a bit about early discussions of generators in the Python community (read the other messages in the thread as well). I think we talked about the articles he mentions way back when. Earlier still, and beyond the discussion by Guido here, was Icon, a clever little language that I have a soft spot for. i don't think we ever fully assessed its influence on Python and other languages.
PeachPy is a Python framework for writing high-performance assembly kernels.
PeachPy aims to simplify writing optimized assembly kernels while preserving all optimization opportunities of traditional assembly.
You can use the same code to generate assembly for Windows, Unix, and Golang assembly. The library handles the various ABIs automatically. I haven't seen this cool project before.
Among the cool features is the ability to invoke the generated assembly as regular Python functions. Nice.
I am imagining that the change happened in Windows 8.1 and a solved problem became unsolved, so how do I do this today? It seems like a relatively fundamental thing, so maybe it would make sense to have this kind of thing in the already portable System.Directory library which currently has things like getModificationTime anyway?
edit: looks like System.IO.hFileSize is what I was looking for. Seems obvious now :P And it appears to be O(1) and all, so hopefully next time I know where to look now :)submitted by wheatBread
[link] [10 comments]
Recently I've been having some fun working through "Learn You a Haskell" and until now, every piece of code in the book has compiled without issue. But now, I've entered this code from the book:initials :: String -> String -> String initials firstName lastName = [f] ++ ". " ++ [l] ++ "." where (f:_) = firstName (l:_) = lastName
and I get this error: "124:25: parse error on input ‘=’" (the line where the error is thrown is the last line of the code under the "where" block, "(l:_) = lastName." My syntax is exactly as in the book. What could be the problem here?submitted by AlanMGodel
[link] [8 comments]
I read part of this paper about LVars.
I don't understand the implementation on page 9. The code is supposed to call analyze on the elements added to analyzedSet as soon as they are added. Unfortunately, the machinery of how analyze is applied to the elements is hidden.
What I don't understand is what the threshold for the get is supposed to be to read the first element of the result.
In general, let's say N threads add elements to a set. The updates are monotonic, but how can I get the elements as they arrive? This would be non-deterministic by definition. That's the point of the producer/consumer pattern.
I'm missing something here...submitted by Kiuhnm
[link] [2 comments]
How would I use an if statement to check if the given input (information) is in my Player data constructor? Such as...data Player = playerA | playerB | playerC data playerInfo = playerInfo Player Int Int information = playerInfo playerA 10 10 newteam :: playerInfo -> Maybe playerInfo newteam (Info p x y) = if (check if p is in Player data constructor) then Just (playerInfo p x y) else Nothing submitted by kendrickisgoat
[link] [4 comments]
I have this code :middleNumber :: Integer -> Integer -> Integer -> Integer middleNumber x y z | between y x z = x | between x y z = y | between z y x = y | otherwise = z between :: Integer -> Integer -> Integer -> Bool between a b c = a <= b && b <= c
on middleNumber 1 2 3 it works fine. But on middlenumber 2 1 3 or 3 1 2 it fails.
How can I make this work. Add quards to between or is there a better way ?submitted by roelofwobben
[link] [11 comments]
Earlier articles: Introduction Common features Page 1 (numerals) Page 2 (arithmetic) Page 3 (exponents) Page 4 (algebra) Page 5 (geometry) Page 6 (chemistry) Page 7 (mass) Page 8 (time and space) Page 9 (physical units)
This is page 10 of the Cosmic Call message. An explanation follows.
The 10 digits are:
The top half of this page is a table of melting points (on the left) and boiling points (on the right) for various substances: hydrogen , carbon , sulfur , zinc , silver , and gold . The temperatures are given in kelvins .
The boiling points depend on pressure, so there is a notation at the bottom of the list that the pressure should be 101300 pascals . This is one standard atmosphere, so it may tell the aliens a little more about our planet.
To help calibrate the kelvins, the bottom of the page is a chart of the temperature increase of water , showing how the temperature stops increasing at the melting point (273K) and the boiling point (373K). This introduces the glyph for temperature , which will recur later.
There are two regrettable things about this chart. One is that the horizontal axis is labeled “time” . Why is the temperature of the water increasing with time? It should be energy.
But a more serious complaint, I think, it that this is the wrong
chart. It depends crucially on the (Earth-)standard atmospheric pressure,
with which the recipients may not be familiar. And the kelvin is not defined
in terms of standard pressure anyway. It is defined in terms of the
triple point of water, the unique, universal temperature and pressure at which
all three states of water can coexist. Why not a temperature and
pressure chart with the triple point labeled? This is something one
might more reasonably expect the aliens to have studied.