DEV Community

Discussion on: Let's go on an adventure, a functional one.

Collapse
 
deciduously profile image
Ben Lovy • Edited

Nice write-up!

learning Haskell and functional programming is like learning everything all over again

This is so incredibly true. I'm interested to hear if anyone actually learned Haskell first, and it was easier because you're not un-learning too.

instead of writing code specifying what it NEEDS to be done I am writing code representing what things ARE

This is pretty much exactly the sentence I keep in my head when I sit down to write functional code, in Haskell or any other language.

I also found the only way to get my head around Haskell was to write bash my head against it until it clicked. Books only helped me to a point...you've gotta write code, which is exactly what you're doing!

For outputting to the console, you want putStr/putStrLn, which can be used inside any function that returns an IO monad. You'll probably also want hFlush from System.IO.

My similarly-spirited experiment led to a console game of TicTacToe, here's the code if you want an example of how I handled user IO.

Collapse
 
patferraggi profile image
Patricio Ferraggi

Thank you very much for commenting, is nice to re check that I am not the only one who struggles with this. Thank you for the resources, I will make sure to read them once I get into the IO monad, I don't want to rush thing so I am following books and coding a long the way while trying to use only what I read.

Haskell is indeed challenging, but it is fun and painful at the same time ahha.

Collapse
 
deciduously profile image
Ben Lovy

I think you're right here too: "this adventure can lead me to a place I would never want to come back from."

I don't use much Haskell anymore, not as much as I should but the process of learning it unlocked something I've never lost - it affects how I approach all problems, even in OOP projects.

Thread Thread
 
patferraggi profile image
Patricio Ferraggi

That is good to hear, for now is only a hunch. I still need to do a lot of learning and practicing before it actually changes the way I solve problems and approach different implementations on my daily OOP job.

Thread Thread
 
deciduously profile image
Ben Lovy • Edited

I think for me it doesn't necessarily always affect my implementations (but definitely some of them), but it did shift how I think about problems in a general sense, and how I explore a problem I don't fully understand.