# Elixir Witchcraft IO monad?

**URL:** <https://forum.devtalk.com/t/elixir-witchcraft-io-monad/62017>\
**Category:** Backend Questions/Help\
**Tags:** elixir, monads\
**Created:** [1 July 2022 08:48 UTC](https://forum.devtalk.com/t/elixir-witchcraft-io-monad/62017 "2022-07-01T08:48:50Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![Fl4m3Ph03n1x](https://forum.devtalk.com/user_avatar/forum.devtalk.com/fl4m3ph03n1x/32/3808_2.png) [@Fl4m3Ph03n1x](https://forum.devtalk.com/u/Fl4m3Ph03n1x)\
**Post date:** [20 July 2022 15:52 UTC](https://forum.devtalk.com/t/elixir-witchcraft-io-monad/62017/3 "2022-07-20T15:52:52Z")

</div>

There has been quite a lengthy discussion in Elixir’s original forum. To summarize:

- Using witchcraft I would have to create the monad myself, and then use it.
- Because of the way said Monad would have to be implemented, Dialyzer would not play well.

> **[Witchcraft to get something similar to the IO Monad (in Haskell, Scala, etc)...](https://elixirforum.com/t/witchcraft-to-get-something-similar-to-the-io-monad-in-haskell-scala-etc-but-in-elixir/48710/12)**
>
> Gradient/Gradualizer would do much better! I’m not sure how complete it is but I’m quite excited for it. Looks great. It’s more of a type checker or compiler feature than a library. The nice thing about it is that for just inferring and restricting...

However there is more to be said. The IO Monad (as we know and love) is more of a consequence of _how_ Haskell works. Its main purpose is to get the correct sequence of actions to perform on a language that is lazily evaluated by default.

Elixir, on the other side, is eagerly evaluated by default. Because of this, algebraic effects could potentially make more sense and be more user friendly in comparison to IO Monads.

> **[An Introduction to Algebraic Effects and Handlers. Invited tutorial paper](https://www.sciencedirect.com/science/article/pii/S1571066115000705?ref=pdf_download&fr=RR-9&rr=72dcdc9c8a1e9241)**
>
> This paper is a tutorial on algebraic effects and handlers. In it, we explain what algebraic effects are, give ample examples to explain how handlers …

Last but not least, at the time of this writing, I waited almost 20 days for a human to reply in the Witchcraft’s GitHub repository. Unfortunately, no one replied, which leads me to believe the project is in a limbo, receiving minimal support only.

> <https://github.com/witchcrafters/witchcraft/issues/121>
>
> I apologize if this is not the correct forum to make these questions. If not, pl…ease let me know the appropriate place and feel free to cancel this issue.
> 
> \------
> 
> Background
> \------------
> 
> I have recently been delving into more functional code. My objective right now is to get something similar to the IO Monad (in Haskell, Scala, etc) but in Elixir. 
> 
> To this extent, I understand \[Witchcraft\](https://github.com/witchcrafters/witchcraft) should be in theory capable of doing it. 
> 
> Doubts
> \----
> 
> However, after reading through their documentation I have some questions:
> 
> \- I was not able to find a clear-cut example of the IO Monad. I have the idea what I have to create Monads myself using one of the sub-libraries, but I am not 100% sure of this.
> \- I am not sure if Dialzyer plays nice with Witchcraft and if it can detect issues if my code is incorrect (like Scala compiler does).
> 
> Could someone help me answer these questions?

Given the huge effort I would have to undergo to integrate Witchcraft into any of my projects, I personally feel like this would not be a wise decision. It’s not a matter of “if I will eventually need help using the library”, it is a matter of “when”.

The questions are answered, and I hope the additional insight provided can be of use to someone.

---

_[View the full topic](https://forum.devtalk.com/t/elixir-witchcraft-io-monad/62017)._
