1
Fork 0
solar-conflux/purescript/abilities/src/Ask.purs

17 lines
331 B
Plaintext
Raw Normal View History

2021-04-01 18:33:36 +02:00
module Ask where
import Prelude hiding (bind,discard)
import Unsafe.Coerce (unsafeCoerce)
class Ask a where
ctx :: a
pure :: forall ctx a. a -> Ask ctx => a
pure a = a
foreign import ask :: forall ctx. ((Ask ctx) => ctx)
handleAsk :: forall a ctx. ctx -> (Ask ctx => a) -> a
handleAsk = unsafeCoerce \c f -> f { ctx: c }