Hello all,

After learning some Haskell for class I realized that the functional 
programming paradigm isn't completely at odds with Nim. Nim supports pure 
functions (so long as you don't use mutable arguments) and has a type-based 
effect tagging system, so it's fairly easy to track side effects and achieve 
referential transparency. The remaining part is to structure code in a 
functional style by replacing iteration with recursion, deep branching with 
pattern matching, and exceptions/sentinel values with algebraic data types 
(except for exceptions thrown by IO and state mutators, perhaps).

So, I know that Nimble has several modules for functional programming. I've 
seen `zero_functional`, `nimfp`, and some functional features in `nimboost`.

My main question is if anyone has tried using these modules (or their own) in 
their projects, and what experiences they had doing so. Most of the Nim 
projects I see on GitHub are imperative. Has anyone made any projects using a 
primarily (although technically impure) functional style? Do you have any 
suggestions for me if I were to take that on myself?

Also, I am in the process of writing a 
[Craft](https://github.com/fogleman/Craft) server in Nim (it uses `async`, and 
I was contemplating doing a redesign using a functional style. I'm afraid the 
application is too stateful to benefit from the functional style. I also know 
that many functional programmers feel that state handling is natural ("Haskell 
is the best imperative language around" seems to be a common rebuke of the idea 
that functional languages can't replace imperative ones).

TL;DR:

  * I'm thinking about functional programming in Nim.
  * I'm curious if anyone has tried it and had a good experience.
  * I'm not sure whether it makes sense to apply the functional style to a 
server program with `async`.



Cheers, twetzel59

Reply via email to