I mean, I know the point of monads. I think I do. They're a powerful tool to help you avoid side effects, think about what you're doing and make it possible for the compiler to do really clever stuff to your code.
I'm trying to do this: I want to write a function that finds out the size of a file. I also want some low-level error handling (because the file may not exist). Wanting to become a true haskeller, I want to not sidestep the monads but bathe in them - absorb them into my essence. Here are my bothers:
The type of my function isfsize :: Num (Maybe a) => FilePath -> IO (Maybe a)
Because my function evaluates to "Just 10000" if the file was 10000 bytes in size, but "Nothing" if the file wasn't found and the function doesFileExist from System.Directory has the type FilePath -> IO Bool so I want to do all of this inside the IO monad. Fine. But when I want to use the value elswehere I have to now dig it out of not one, but two monads. That brought me to this post where the guy basically just asks "wow do I have to all this heavy lifting with <$> and liftM and fmap just to have error handling and file IO"? The responses are quite illuminating: one guy says "learn the corresponding type class for the monads and refactor the code to use those instead". So... did I spend hours and hours learning about monoids and functors and applicative functors just to find out that there is another layer I have to learn before I can actually use these concepts?
I get what monads are for, and I really appreciate the idea. I do! It's just that at this point we're talking about an energy investment of hours upon hours to learn how to do something that will take a full pagedown of super dense Haskell code that would be like 10 lines of (incredibly unsafe) C. Wasn't the point of Haskell to make it more readable and more elegant? Because it seems like that is the case as long as you're doing pure stuff with folds and really neat compositions but as soon as you want your computer to actually do something that resembles an app or a program it turns into this mess. I mean... I can't be the only one to want error handling and file IO in the same program?
Bit of a rant, yes, but at the heart of it lies an effort to get better at Haskell and actually write usable code. Any replies are appreciated!submitted by Krexington_III
[link] [28 comments]
I've just release a new version of my dynamic time warping implementation. As this release marks the introduction of automatic testing and deployment (Build Status) via Travis CI, the library is quite stable and feature complete I thought it appropriate to bump the version number to the all famous 1.0.
This has mostly been a lesson in library design, maintenance and deployment for me and I am positively surprised that this has become so easy.submitted by goliatskipson
Hi, trying to install and run hmatrix on Windows 7. It fails with the following error as described here: https://github.com/albertoruiz/hmatrix/issues/91 and no answer has been posted. I've searched and searched and found a few results with similar issues, but no answers. Any help would be much appreciated. Thank you.submitted by shellraptor
[link] [7 comments]
Final CFP: WPTE 2015 Second International Workshop on Rewriting Techniques for Program Transformations and Evaluation
Hey this always struck me as odd. Why do we newtype types to use different istances where it would make a lot more sense to name the instance instead? We seem to be naming the wrong thing.submitted by arianvp
[link] [38 comments]
Enter this number https://gist.github.com/eccstartup/382579e0a4ef9133eb16 1312414124532675478362532543571329085712389578957198523598236057236457230478923749028357328974892375829037589230748923569823604327894723589072389547328957238907523895789207589230758932758903274892305692803567892037145892137580927389573289475238956729803659028375892037698023716891205237509812759807589263108972589236589237489326589325790238502156728013523809759823
Enter it^2 for 9 times
I get a Bus error: 10.
I use ghcformacosx, with version 7.10.1 in Yosemite. I notice that not all really large numbers can reproduces this, but this one can cause bus error again and again, even after a restart. I admit that this number is typed randomly if you want to know how I get it. What could be the reason?submitted by eccstartup
[link] [21 comments]