DEV Community

miku86
miku86

Posted on • Originally published at miku86.com

#100DaysOfHaskell: Start

When you have a look at all my post, you can see that many of them are about JavaScript.

The more I've grown as an engineer/developer, the more I've moved away from caring too much about implementation details.

Tools like languages, frameworks and libraries come and go, but ideas, concepts and patterns stay way longer.

This is why I'm very open-minded towards learning new concepts.

Functional Programming is one of these concepts I find very interesting and intuitive.

Nowadays I'm more into mentoring, especially about ideas and concepts, so I don't program that much.

What do I do? So I already did a lot of functional programming in JavaScript and TypeScript, because this is what you use when you do a lot of React stuff, but I want to fully immerse into functional programming, not just when I need it.

This is why I decided to have a look at Haskell and I just started a #100DaysOfHaskell challenge. Because I want to see these new concepts in action, I try do some programming with Haskell every day.

You will see my progress from time to time on my blog and live on twitter.

Currently, my code is on repl.it until I'll find a better solution. If you know about a better solution (the code breaks when you hit the run button), let me know!

Send me a tweet or a message if you've got some ideas or questions!

Top comments (4)

Collapse
 
shadowdevil profile image
Shadow Devil

Very cool post!
I think the problem with repl.it is, that you have to have a "main :: IO ()" function that is being executed when running. You could do a short demonstration of your defined functions like this:

-- create list of x-steps n-times
-- e.g. 2 3 => [2,4,6]
countBy x n = [x | x <- [x, 2*x..n*x]]

-- create sum of all positive input numbers
-- e.g. [1, 2, -3] => 1 + 2 => 3
positiveSum xs = sum [ x | x <- xs, x > 0]

main:: IO ()
main = do
    putStrLn "countBy: Create list of x-steps n-times"
    putStrLn "e.g. 2 3 => [2,4,6]"
    print (countBy 2 3)
    putStrLn "positiveSum: Create sum of all positive input numbers"
    putStrLn "e.g. [1, 2, -3] => 1 + 2 => 3"
    print (positiveSum [1, 2, -3])
Enter fullscreen mode Exit fullscreen mode
Collapse
 
miku86 profile image
miku86

Thanks,
I will have a look at it!
I currently use :l main all the time.

Collapse
 
kosich profile image
Kostia Palchyk

Sounds like an awesome journey! :)
P.S.: I've found codewars Haskell tasks to be useful to challenge my rigid mind (guess, any such platform will do). But alas, still haven't learned even a 10th of the enormous Haskell might.

Collapse
 
trivelt profile image
Maciej Michalec

Fingers crossed! I also learn the secrets of Haskell currently. :)