@Jello_Raptor
Thanks, that makes sense! I'm not very familiar with Haskell syntax, but it seems like your Flee monad is just working more or less like a closure would in JavaScript (and I can definitely see how that would be useful here).. that's a bit different from how I'd learned about Monads,
here and on
Wikipedia.
They describe them more as Type enhancers/wrappers, but here there's no wrapped base type at all! I guess a Monad the way they've describe it reduces to essentially a JavaScript closure when the wrapped type is void?
Yup, but the beauty of it is you can have arbitrary wrapped types. In our case, let's say we have a tactical plan to determine whether we should go to Uzu, Sea, or Vegetable. We could create a type `
data ReturnLoc = Uzu | Sea | Vegetable` and our tactical plan (of type `
TacticalPlan ReturnLoc`) could
return the particular location we decided was best to the strategic plan, which can then use that information as part of the choices it's capable of making.
Not to mention, unlike a closure, you have much more control over what can happen within a monad by controlling the primitive functions and constructors that the user has access to.
Mind, having a monad that can only enclose a void type is a perfectly useful pattern on its own. In fact you should take a look at the
Shake haskell build system for how it uses monads in the way I'm suggesting. The
API docs for the same are cool reading too.
It's worth taking the example they provide and looking at the types of all the statements and how they interact to provide both a declarative outer monad (for holding build system rules that all exist independently) and an imperative inner monad (for the series of actions that make up a single rule within the build system).
Oh, that reminds me, we could go with the "barrel full of water with a white-hot piece of metal inside it sealed inside a PMYF scroll" method of mist generation for combat use. In fact, we really really should. That would be a good way for Nobby to practice with mist, too.
I would like to point out that that would be more steam than mist. Incredibly painful to those who come in contact with it before it cools off, and more than enough to inflict third degree burns.
Admittedly, that has its own uses but "safe training aid" isn't one of them.