This article talks about embedding a simple Dhall configuration within a Servant app.
https://matsumonkie.fr/post/5
Another nice article. Thanks!
A couple of questions:
- What do you think about passing configurations flags as environment variables? Is that bad practice?
- What do you think about having something like
type App = (<constraints>)
or evennewtype App = <transformers-stack>
instead of using mtl in functions?
Btw ask <&> f
can also be written as asks f
Thank you gilmi!
What do you think about having something like type App = () or even newtype App = instead of using mtl in functions?
I personally prefer to use constraints rather than one huge application type. It’s more composable, and readable (IMO). It’s nice to be able to tell at a glance, this function needs IO
, Reader
,…
Also, sometimes, for a given function, you don’t need the whole stack capabilities:
closeDBConnection :: (IO.MonadIO m) => PG.Connection -> m () -- doesn't need MonadReader
closeDBConnection connection =
IO.liftIO $ PG.close connection
There is a nice ghc option - -Wredundant-constraints
that triggers a warning if I add MonadReader
constraint on this function.
What do you think about passing configurations flags as environment variables? Is that bad practice?
I personally like having a static and typed configuration with Dhall for medium to big projects but for everything else I don’t mind using environment variable, yaml, json,…
Btw ask <&> f can also be written as asks f
Good pick! I edited the article.
Thank you for the posts! I’m gonna start reading your blog posts when I’m less busy with school. This is right up my alley.
You’re welcome! Don’t hesitate to ask if there’s anything unclear