Files
enso/README.md

3.6 KiB

Enso - The Minimalist IO Monad Library

Enso is a minimal IO Monad library that provides only absolute basics, nothing more and nothing less. It's not very robust, and that's by design. It's not amazing, and that's also by design. Enso is both something I wrote to learn how Monads (such as IO Monads) work in hopes to respark my interest in Functional Programming, as well as a utility built to make the development of my projects heavily utilizing the paradigm much easier.

As a result, Enso is not exactly fantastical and may not be for you, unless you don't mind the batteries not included mentality of Enso. Furthermore, I am not amazing at Functional Programming, and I have learned all of what I know about it through Haskell. As well, I'm not an academic of any sort (not a Computer Sciences major nor student) and thus this most likely is not the most impressive attempt at an IO Monad. I'm more of the engineer praxis type, and I just wanted to see whether I can even do the task.

Usage

Enso provides the IO Thunk in order to handle data and functions. Functions and any data made pure via to_IO are lazily evaluated and then able to be used on the spot or when necessary, with the run function intended to sugar the usage of functions stored this way. flatmap, map, join, and lift are also provided in order to be used with the IO Thunk or with any other potentially impure functions to be executed in the Monad's context. It's mostly bare bones other than that besides readln to read from a file descriptor and strput to write a string to STDOUT.

As well, Enso provides attempt to help work with effectful procedures in Nim that have the capability to raise an Exception, attempt moves an IO Thunk with the capability to raise an Exception to be detonated within an unsafe procedure where the effect will happen, and passing off a Some or None to then be evaluated for handling any potential errors in a safer, much more graceful manner. attempt pairs fantastically with lift for removing any potential issues caused by effectful code.

It is important still as the programmer to understand that while many of Enso's provided utilities can allow you to perform nicer Functional Programming in Nim, it does not hold your hand the way a language like Haskell or OCaml will with the paradigm, and you have to hold yourself accountable to the paradigm. That is to say, how you use Enso will reflect who you are as a programmer and who you are when the compiler stops holding your hand. Enso also will teach the academics how to be engineers and the engineers how to be academics.

Dependencies

Enso doesn't depend on anything but the Nim language itself. As such, Enso is meant to be a batteries not included library that provides niceties to make Functional Programming a little quicker, or at least I tell myself that as I really just designed this out of sheer curiosity.

Why should I use Enso?

The short answer, you shouldn't unless you are insane like I am.

The long answer is that maybe you're a lot like me and want to better understand how Functional Programming works under the hood for some reason, and you want to tinker around with building the systems yourself too. I also built Enso because the only Monad library I found for Nim is practically abandoned, and I was psychotic enough to start a project with an associate where we decided to use Functional Programming for it, but we had no good systems to use for IO that added a few bells and whistles for us. For all I know, Enso may get new code should we need more. I don't quite know yet.

If you like Enso, great. If you don't like Enso, great.