Skip to content

Commit

Permalink
doctest
Browse files Browse the repository at this point in the history
  • Loading branch information
arybczak committed Aug 22, 2024
1 parent 3f9d2bd commit 8e96de7
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
1 change: 1 addition & 0 deletions doctest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ run_doctest() {
-XLambdaCase \
-XMultiParamTypeClasses \
-XNoStarIsType \
-XPolyKinds \
-XRankNTypes \
-XRecordWildCards \
-XRoleAnnotations \
Expand Down
18 changes: 18 additions & 0 deletions effectful-core/src/Effectful/Labeled.hs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,24 @@ import Effectful
import Effectful.Dispatch.Static

-- | Assign a label to an effect.
--
-- The constructor is for sending labeled operations of a dynamically dispatched
-- effect to the handler:
--
-- >>> import Effectful.Dispatch.Dynamic
--
-- >>> :{
-- data X :: Effect where
-- X :: X m Int
-- type instance DispatchOf X = Dynamic
-- :}
--
-- >>> :{
-- runPureEff . runLabeled @"x" (interpret_ $ \X -> pure 333) $ do
-- send $ Labeled @"x" X
-- :}
-- 333
--
newtype Labeled (label :: k) (e :: Effect) :: Effect where
-- | @since 2.4.0.0
Labeled :: forall label e m a. e m a -> Labeled label e m a
Expand Down
2 changes: 1 addition & 1 deletion effectful/tests/LabeledTests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ test_labeledSend = runEff $ do

data X :: Effect where
X1 :: X m Int
X2 :: X m Int
X2 :: (X :> es, Labeled "x" X :> es) => X (Eff es) Int

type instance DispatchOf X = Dynamic

Expand Down

0 comments on commit 8e96de7

Please sign in to comment.