Hey guys! I'm new to this subreddit. I have recently gotten into Haskell, and I'm loving it so far. The functional paradigm is a really fun way to reason about programming.
So, like the title says, this summer I do not have an internship lined up, so my plan is to do a lot of personal projects, post a lot on github, contribute to open source projects, and possibly attend tech meetups to network. As such, I should probably learn as much as I can this summer, right?
I really want to get good at Haskell, though, like really really good. And functional programming in general. My question is, if I spend all of my summer doing Haskell, getting good at it and doing a lot of good work with it, would I have a shot at getting interviews for places that use functional programming, even if I don't have too much experience with other languages?
Either way, I will probably dabble in more popular languages like Scala, Erlang, F#, etc, but as of now I'm making haskell a priority. Should I split the time more evenly, or will learning haskell pay more dividends when it comes to being a better programmer, and still not hurt my chances of getting interviews at places whose stack is heavily functional based?
Thanks for reading!submitted by uncountableB
[link] [4 comments]
I'm starting out in Haskell and trying to build something that requires reading protocol buffers in ghc 7.10. I'm using 7.10 because it's the latest and I don't want to learn old stuff that I have to later unlearn and it's what I have on my Linux distro (Arch Linux). Is there a package for reading protocol buffers that I can use?
protocol-buffers: Build errors when I try to cabal install it.
protobuf: I can't get code to work that's modeled after the first example in the hackage docs. I get a parse error on the part where I express the field tag. (http://hackage.haskell.org/package/protobuf-0.2.0.4/docs/Data-ProtocolBuffers.html)
protobuf-native: Seems to require interfacing with C++. I'm not sure whether I'm ready for that.submitted by Syncopat3d
[link] [9 comments]
Last evening, Codingame held a “Programming World Cup” titled “There is no Spoon”. The format is that within four hours, you get to write a program that solves a given task. Submissions are first rated by completeness (there are 13 test inputs that you can check your code again, and further hidden tests that will only be checked after submission) and then by time of submission. You can only submit your code once.
What I like about Codingame is that they support a great number of programming languages in their Web-“IDE”, including Haskell. I had nothing better to do yesterday, so I joined. I was aiming for a good position in the Haskell-specific ranking.
After nearly two hours my code completed all the visible test cases and I submitted. I figured that this was a reasonable time to do so, as it was half-time and there are supposed to be two challenges. I turned out that the first, quite small task, which felt like a warm-up or qualification puzzle, was the first of those two, and that therefore I was done, and indeed the 5th fastest to complete a 100% solution! With only less than 5 minutes difference to the 3rd, money-winning place – if I had known I had such a chance, I had started on time...
Having submitted the highest ranked Haskell code, I will get a T-Shirt. I also defended Haskell’s reputation as an efficient programming language, ranked third in the contest, after C++ (rank 1) and Java (rank 2), but before PHP (9), C# (10) and Python (11), listing only those that had a 100% solution.
The task, solving a Bridges puzzle, did not feel like a great fit for Haskell at first. I was juggling Data.Maps around where otherwise I’d simple attach attributes to object, and a recursive function simulated nothing but a plain loop. But it played off the moment I had to implement guessing parts of the solution, trying what happens and backtracking when it did not work: With all state in parameters and pure code it was very simple to get a complete solution.
My code is of course not very polished, and having the main loop live in the IO monad just to be able to print diagnostic commands is a bit ugly.
The next, Lord of the Ring-themed world cup will be on June 27th. Maybe we will see more than 18 Haskell entries then?
It seems to me that many of the problems with cabal are due to precompiling packages, because, as far as I can see, Haskell never guarantees ABI compatibility.
Why, then, are packages precompiled, instead of coherently building all the modules used from source when the program is compiled?submitted by 1-05457
[link] [8 comments]
Pretty cool that we made it to 20k readers. That makes /r/haskell the 7th largest language community on reddit. Not bad for an obscure academic language ;)dons
[link] [50 comments]
I learned haskell some years ago, but then I stopped and now I really want to learn it, but what stopped me the first time was that I found haskell like a toy-language or a language for specific application, somewhere I am a amateur programmer and I'd like to use it for web developpement, little interpreter/compilater etc.
So the question : Can a student with basic skills in maths (ie no formation in maths) can become good in Haskell, or I will be blocked by my lack of skills anywhere in my learning?
Too, does Haskell really can be use for web developpement and general purpose, or its kinda tricky to use it like that?
Thanks for your answers and sorry for my english.submitted by vildric
[link] [26 comments]
Summary: Sometimes source files get deleted, and build products become stale. Using Shake, you can automatically delete them.
Imagine you have a build system that compiles Markdown files into HTML files for your blog. Sometimes you rename a Markdown file, which means the corresponding HTML will change name too. Typically, this will result in a stale HTML file being left, one that was previously produced by the build system, but will never be updated again. You can remove that file by cleaning all outputs and running the build again, but with the Shake build system you can do better. You can ask for a list of all live files, and delete the build products not on that list.
A basic Markdown to HTML converter
Let's start with a simple website generator. For each Markdown file, with the extension .md, we generate an HTML file. We can write that as:import Development.Shake
main :: IO ()
main = shakeArgs shakeOptions $ do
action $ do
mds <- getDirectoryFiles "." ["//*.md"]
need ["output" </> x -<.> "html" | x <- mds]
"output//*.html" %> \out -> do
let src = dropDirectory1 out -<.> "md"
cmd "pandoc -s -o" [out, src]
phony "clean" $ do
removeFilesAfter "output" ["//*.html"]
Nothing too interesting here. There are three parts:
- Search for all .md files, and for each file foo/bar.md require output/foo/bar.html.
- To generate an .html file, depend on the source file then run pandoc.
- To clean everything, delete all .html files in output.
Using a new feature in Shake 0.15, we can name save this script as Shakefile.hs and then:
- shake will build all the HTML files.
- shake -j0 will build all the files, using one thread for each processor on our system.
- shake output/foo.html will build just that one HTML file.
- shake clean will delete all the HTML files.
Removing stale files
Now let's imagine we've added a blog post using-pipes.md. Before publishing we decide to rename our post to using-conduit.md. If we've already run shake then there will be a stale file output/using-pipes.html. Since there is no source .md file, Shake will not attempt to rebuild the file, and it won't be automatically deleted. We can do shake clean to get rid of it, but that will also wipe all the other HTML files.
We can run shake --live=live.txt to produce a file live.txt listing all the live files - those that Shake knows about, and has built. If we run that after deleting using-pipes.md it will tell us that using-conduit.md and output/using-conduit.md are both "live". If we delete all files in output that are not mentioned as being live, that will clean away all our stale files.
Using Shake 0.15.1 (released in the last hour) you can write:import Development.Shake
pruner :: [FilePath] -> IO ()
pruner live = do
present <- listFilesRecursive "output"
mapM_ removeFile $ map toStandard present \\ map toStandard live
main :: IO ()
main = shakeArgsPrune shakeOptions pruner $ do
... as before ...
Now when running shake --prune it will build all files, then delete all stale files, such as output/using-pipes.html. We are using the shakePrune function (just sugar over --live) which lets us pass a pruner function. This function gets called after the build completes with a list of all the live files. We use listFilesRecursive from the extra package to get a list of all files in output, then do list difference (\\) to delete all the files which are present but not live. To deal with the / vs \ path separator issue on Windows, we apply toStandard to all files to ensure they match.
A few words of warning:
- If you run shake output/foo.html --prune then it will only pass output/foo.html and foo.md as live files, since they are the only ones that are live as you have asked for a subset of the files to be built. Generally, you want to enable all sensible targets (typically no file arguments) when passing --prune.
- Sometimes a rule will generate something you care about, and a few files you don't really bother tracking. As an example, building a GHC DLL on Windows generates a .dll and a .dll.a file. While the .dll.a file may not be known to Shake, it probably doesn't want to get pruned. The pruning function may need a few special cases, like not deleting the .dll.a file if the .dll is live.
Often, I when reconciliating accounting stuff, I need to decompose a sum of numbers as a sum of other numbers (all numbers are given). For example I have an invoice of 10, two payments of 3 and 5 and credit note of 2. I would need something which given [2,3,5,10] returns [-10, 2,3,5] ("3+5 - 10 +2 == 0" ) as well all other possibilties.
I'm sure I kind do it myself, but I don't like to reinvent the wheel, so does anybody knows if such a package exists or one which could facilitate this problem ?submitted by maxigit
[link] [18 comments]
class Functor f where
fmap :: (a -> b) -> f a -> f b
I guess f is not a type , but rather a type constuctor?submitted by tmtwd
[link] [14 comments]