Hello,
> Is there any recommended way of passing around (immutable) config?
>
> When my project loads I read various config stuff from various files.
> If it wasn't a Brick app I'd use `ReaderT` to pass it around the
> place. But given Brick's type is already using a few layers of monads,
> adding *another* one seems like it might get a bit confusing - I did
> try this, but got a bit stuck. The only other way I can think would be
> to add it to my State. Am I missing something obvious? Still fairly
> new to Haskell.
Another approach is to bind such configuration to your top-level
functions like so, e.g.,
mkApp :: Config -> App s e n
mkApp cfg =
App { appDraw = drawUI cfg
, appChooseCursor = ...
, appHandleEvent = appEvent cfg
, appStartEvent = ...
, appAttrMap = ...
}
main :: IO ()
main = do
cfg <- ...
let app = mkApp cfg
...
--
Jonathan Daugherty