Created
February 24, 2023 09:58
-
-
Save escherlies/2ec3cdfd517704432edfa753b6627d02 to your computer and use it in GitHub Desktop.
An Elm context type that can be run everywhere. Like a Reader.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Context exposing (..) | |
type Context a b | |
= WithContext (a -> b) | |
withContext : (a -> b) -> Context a b | |
withContext = | |
WithContext | |
runContext : Context a b -> a -> b | |
runContext (WithContext fn) a = | |
fn a |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Upon further discussion, this actually is a Reader. 😄
See Punie/elm-reader
With open records as environment, the environments can be composed and scoped.