Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- type LocalReader i = Output (LocalReaderZone i)
- data LocalReaderZone i
- data ActionList r rInitial
- = SingleAction (Action r rInitial)
- | MultipleActions [ActionList r rInitial]
- type family AllFirstOrder xs where ...
- class Member (State (ActionsU effs rInitial)) r => MockInterpret (effs :: EffectRow) (r :: EffectRow) rInitial where
- interpretMock :: Sem r a -> Sem '[State (ActionsU effs rInitial), Error MockError'] a
- data MockResult a
- newtype MockError' = MockErrorMessage Text
- type ActionsU r rInitial = [Action r rInitial]
- data Action r rInitial
- = ExpectRequest (DSumI (Union r rInitial))
- | UnsafeForceReturn Any
- type DSumI f = DSum f Identity
- pattern (:->) :: f m a -> a -> DSumI (f m)
- forgetM :: forall (f :: Effect) m a. f m a -> f [] a
- mockSem :: forall ra rb e m x r. (GShow (e []), GEq (e []), Member (State (ActionsU ra rb)) r, Member e ra, GShow (Union ra []), Member (Error MockError') r) => e m x -> Sem r x
- verifyU :: forall (f :: EffectRow) w r. GShow (Union f []) => Either MockError' ([Action f r], w) -> Either MockError' w
- runMockM :: forall mockedEffs a effs rInitial. (GShow (Union mockedEffs []), MockInterpret mockedEffs effs rInitial, effs ~ (mockedEffs ++ '[State (ActionsU mockedEffs rInitial), Error MockError']), AllFirstOrder mockedEffs) => ActionList mockedEffs rInitial -> Sem effs a -> MockResult a
- runMockM' :: forall mockedEffs a effs rInitial. (GShow (Union mockedEffs []), MockInterpret mockedEffs effs rInitial, effs ~ (mockedEffs ++ '[State (ActionsU mockedEffs rInitial), Error MockError']), AllFirstOrder mockedEffs) => ActionList mockedEffs rInitial -> Sem effs a -> IO a
- runMockMList :: forall mockedEffs a effs rInitial. (GShow (Union mockedEffs []), MockInterpret mockedEffs effs rInitial, effs ~ (mockedEffs ++ '[State (ActionsU mockedEffs rInitial), Error MockError']), AllFirstOrder mockedEffs) => ActionsU mockedEffs rInitial -> Sem effs a -> MockResult a
- gshow' :: GShow f => f a -> Text
- expectActions :: [Action r rInitial] -> ActionList r rInitial
- flattenActionList :: ActionList r rInitial -> [Action r rInitial]
- (===-) :: Member e r => e (Sem rInitial) a -> a -> ActionList r (Sem rInitial)
- runReaderMock :: forall i r a. Member (LocalReader i) r => i -> Sem (Reader i ': r) a -> Sem r a
- localReaderBegin :: forall i r rInitial. Member (LocalReader i) r => i -> ActionList r (Sem rInitial)
- localReaderEnd :: forall i r rInitial. Member (LocalReader i) r => ActionList r (Sem rInitial)
- localReader :: forall i r rInitial. Member (LocalReader i) r => i -> ActionList r (Sem rInitial) -> ActionList r (Sem rInitial)
- localReaderAborted :: forall i r rInitial. Member (LocalReader i) r => i -> ActionList r (Sem rInitial) -> ActionList r (Sem rInitial)
- inj :: forall e (r :: [(Type -> Type) -> Type -> Type]) (rInitial :: EffectRow) a. Member e r => e (Sem rInitial) a -> Union r (Sem rInitial) a
Documentation
type LocalReader i = Output (LocalReaderZone i) #
data LocalReaderZone i #
Instances
Eq i => Eq (LocalReaderZone i) # | |
Defined in Polysemy.Mock (==) :: LocalReaderZone i -> LocalReaderZone i -> Bool # (/=) :: LocalReaderZone i -> LocalReaderZone i -> Bool # | |
Show i => Show (LocalReaderZone i) # | |
Defined in Polysemy.Mock showsPrec :: Int -> LocalReaderZone i -> ShowS # show :: LocalReaderZone i -> String # showList :: [LocalReaderZone i] -> ShowS # |
data ActionList r rInitial #
To be used with OverloadedLists
SingleAction (Action r rInitial) | |
MultipleActions [ActionList r rInitial] |
Instances
IsList (ActionList r rInitial) # | |
Defined in Polysemy.Mock type Item (ActionList r rInitial) # fromList :: [Item (ActionList r rInitial)] -> ActionList r rInitial # fromListN :: Int -> [Item (ActionList r rInitial)] -> ActionList r rInitial # toList :: ActionList r rInitial -> [Item (ActionList r rInitial)] # | |
Semigroup (ActionList r rInitial) # | |
Defined in Polysemy.Mock (<>) :: ActionList r rInitial -> ActionList r rInitial -> ActionList r rInitial # sconcat :: NonEmpty (ActionList r rInitial) -> ActionList r rInitial # stimes :: Integral b => b -> ActionList r rInitial -> ActionList r rInitial # | |
Monoid (ActionList r rInitial) # | |
Defined in Polysemy.Mock mempty :: ActionList r rInitial # mappend :: ActionList r rInitial -> ActionList r rInitial -> ActionList r rInitial # mconcat :: [ActionList r rInitial] -> ActionList r rInitial # | |
type Item (ActionList r rInitial) # | |
Defined in Polysemy.Mock |
type family AllFirstOrder xs where ... #
AllFirstOrder '[] = () | |
AllFirstOrder (x ': xs) = (FirstOrder x "runMockM", AllFirstOrder xs) |
class Member (State (ActionsU effs rInitial)) r => MockInterpret (effs :: EffectRow) (r :: EffectRow) rInitial where #
interpretMock :: Sem r a -> Sem '[State (ActionsU effs rInitial), Error MockError'] a #
Instances
(GShow (Union effs []), GShow (r []), GEq (r []), Member r effs, MockInterpret effs (ra ': (rs ': rw)) rInitial, Member (State (ActionsU effs rInitial) :: (Type -> Type) -> Type -> Type) (r ': (ra ': (rs ': rw))), FirstOrder r "interpretMock", Member (Error MockError' :: (Type -> Type) -> Type -> Type) (rs ': rw), Member (Error MockError' :: (Type -> Type) -> Type -> Type) (ra ': (rs ': rw))) => MockInterpret effs (r ': (ra ': (rs ': rw))) rInitial # | |
Defined in Polysemy.Mock interpretMock :: Sem (r ': (ra ': (rs ': rw))) a -> Sem '[State (ActionsU effs rInitial), Error MockError'] a # | |
(GShow (r []), GEq (r []), Member r effs) => MockInterpret effs '[State (ActionsU effs rInitial) :: (Type -> Type) -> Type -> Type, Error MockError' :: (Type -> Type) -> Type -> Type] rInitial # | |
Defined in Polysemy.Mock interpretMock :: Sem '[State (ActionsU effs rInitial), Error MockError'] a -> Sem '[State (ActionsU effs rInitial), Error MockError'] a # |
data MockResult a #
Instances
Eq a => Eq (MockResult a) # | |
Defined in Polysemy.Mock (==) :: MockResult a -> MockResult a -> Bool # (/=) :: MockResult a -> MockResult a -> Bool # | |
Show a => Show (MockResult a) # | |
Defined in Polysemy.Mock showsPrec :: Int -> MockResult a -> ShowS # show :: MockResult a -> String # showList :: [MockResult a] -> ShowS # |
newtype MockError' #
Instances
Eq MockError' # | |
Defined in Polysemy.Mock (==) :: MockError' -> MockError' -> Bool # (/=) :: MockError' -> MockError' -> Bool # | |
Show MockError' # | |
Defined in Polysemy.Mock showsPrec :: Int -> MockError' -> ShowS # show :: MockError' -> String # showList :: [MockError'] -> ShowS # | |
IsString MockError' # | |
Defined in Polysemy.Mock fromString :: String -> MockError' # | |
Exception MockError' # | |
Defined in Polysemy.Mock toException :: MockError' -> SomeException # fromException :: SomeException -> Maybe MockError' # displayException :: MockError' -> String # | |
(GShow (r []), GEq (r []), Member r effs) => MockInterpret effs '[State (ActionsU effs rInitial) :: (Type -> Type) -> Type -> Type, Error MockError' :: (Type -> Type) -> Type -> Type] rInitial # | |
Defined in Polysemy.Mock interpretMock :: Sem '[State (ActionsU effs rInitial), Error MockError'] a -> Sem '[State (ActionsU effs rInitial), Error MockError'] a # |
ExpectRequest (DSumI (Union r rInitial)) | |
UnsafeForceReturn Any | Escape hatch, use with caution, expect segfaults |
Instances
(GShow (r []), GEq (r []), Member r effs) => MockInterpret effs '[State (ActionsU effs rInitial) :: (Type -> Type) -> Type -> Type, Error MockError' :: (Type -> Type) -> Type -> Type] rInitial # | |
Defined in Polysemy.Mock interpretMock :: Sem '[State (ActionsU effs rInitial), Error MockError'] a -> Sem '[State (ActionsU effs rInitial), Error MockError'] a # |
forgetM :: forall (f :: Effect) m a. f m a -> f [] a #
We do only care about data in GADT, we can do unsafe coerce as long as our effect is first order
mockSem :: forall ra rb e m x r. (GShow (e []), GEq (e []), Member (State (ActionsU ra rb)) r, Member e ra, GShow (Union ra []), Member (Error MockError') r) => e m x -> Sem r x #
verifyU :: forall (f :: EffectRow) w r. GShow (Union f []) => Either MockError' ([Action f r], w) -> Either MockError' w #
runMockM :: forall mockedEffs a effs rInitial. (GShow (Union mockedEffs []), MockInterpret mockedEffs effs rInitial, effs ~ (mockedEffs ++ '[State (ActionsU mockedEffs rInitial), Error MockError']), AllFirstOrder mockedEffs) => ActionList mockedEffs rInitial -> Sem effs a -> MockResult a #
runMockM' :: forall mockedEffs a effs rInitial. (GShow (Union mockedEffs []), MockInterpret mockedEffs effs rInitial, effs ~ (mockedEffs ++ '[State (ActionsU mockedEffs rInitial), Error MockError']), AllFirstOrder mockedEffs) => ActionList mockedEffs rInitial -> Sem effs a -> IO a #
runMockMList :: forall mockedEffs a effs rInitial. (GShow (Union mockedEffs []), MockInterpret mockedEffs effs rInitial, effs ~ (mockedEffs ++ '[State (ActionsU mockedEffs rInitial), Error MockError']), AllFirstOrder mockedEffs) => ActionsU mockedEffs rInitial -> Sem effs a -> MockResult a #
expectActions :: [Action r rInitial] -> ActionList r rInitial #
Use when OverloadedLists are not enabled
flattenActionList :: ActionList r rInitial -> [Action r rInitial] #
runReaderMock :: forall i r a. Member (LocalReader i) r => i -> Sem (Reader i ': r) a -> Sem r a #
Run (Reader i) effect while emitting calls to (LocalReaderZone i) effect when local zone is entered and leaved.
localReaderBegin :: forall i r rInitial. Member (LocalReader i) r => i -> ActionList r (Sem rInitial) #
localReaderEnd :: forall i r rInitial. Member (LocalReader i) r => ActionList r (Sem rInitial) #
localReader :: forall i r rInitial. Member (LocalReader i) r => i -> ActionList r (Sem rInitial) -> ActionList r (Sem rInitial) #
localReaderAborted :: forall i r rInitial. Member (LocalReader i) r => i -> ActionList r (Sem rInitial) -> ActionList r (Sem rInitial) #
When computation is aborted with exception localReaderEnd is not registered as local computation does not return