Skip to content

Instantly share code, notes, and snippets.

@lunaris
Last active March 7, 2016 16:43
Show Gist options
  • Save lunaris/3fcf9ea12e99a7af65c5 to your computer and use it in GitHub Desktop.
Save lunaris/3fcf9ea12e99a7af65c5 to your computer and use it in GitHub Desktop.
module Test where
import Control.Monad.Aff (Aff, runAff)
import Control.Monad.Eff (Eff)
import Control.Monad.Eff.Console (CONSOLE, log)
import Prelude ((<>), bind, pure, unit)
type MonadA m
= { opA :: m String
}
monadA :: forall eff. MonadA (Eff (console :: CONSOLE | eff))
monadA
= { opA: do
log "opA WOOP"
pure "opA Result"
}
type MonadB m
= { opB :: m String
}
monadB :: forall eff. MonadB (Eff eff)
monadB
= { opB: pure "opB Result"
}
affMonadB :: forall eff. MonadB (Aff eff)
affMonadB
= { opB: pure "opB Aff Result"
}
type TestProps eff
= { someMonadA :: MonadA (Eff eff)
, someMonadB :: MonadB (Aff eff)
}
foreign import data SomeEff :: !
foreign import someThingArbitrary
:: forall eff.
(String -> Eff (someEff :: SomeEff | eff) String)
-> Eff eff String
thisWorks :: forall eff.
TestProps eff
-> Eff eff String
thisWorks props
= do
s1 <- someThingArbitrary \s -> pure s
s2 <- props.someMonadA.opA
pure (s1 <> s2)
thisFails :: forall eff.
TestProps eff
-> Eff eff String
thisFails props
= do
someThingArbitrary \_ ->
props.someMonadA.opA
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment