[Haskell-beginners] How to structure an application?

Magnus Therning magnus at therning.org
Tue Jun 30 21:54:13 UTC 2020


Tilmann <t_gass at gmx.de> writes:

> Hi,
>
> I hope to get some advice on how to structure an application. So I
> acquire a handle early on that I use all over the app, but I don't
> want to pass the handle itself around, but wrap the handle with
> "commands" that a) make a nicer api and/or b) only allow specific
> usecases of the handle. I tried and failed to use MonadReader in a
> straightforward way and now I'm wondering what options there are.
> Looking forward to your feedback,

Below a certain size I'd actually consider just passing the handle
around, possibly in a type holding other info that's needed "all over."

At some point that becomes unwieldy and then I'd look at things like

- monad transformers (like you have below)
- tagless final: https://serokell.io/blog/2018/12/07/tagless-final
- readerT design pattern: https://www.fpcomplete.com/blog/2017/06/readert-design-pattern

I'm not too experienced with them, but I'm guessing free monads/effects
would be an alternative too...

/M

--
Magnus Therning              OpenPGP: 0x927912051716CE39
email: magnus at therning.org
twitter: magthe              http://magnus.therning.org/

I am always doing that which I cannot do, in order that I may learn
how to do it.
     — Pablo Picasso
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20200630/fc1d0c2c/attachment.sig>


More information about the Beginners mailing list