mirror of
https://github.com/polysemy-research/polysemy.git
synced 2024-11-30 07:13:55 +03:00
6ece463ea8
* Remove forklift * Remove lowerResource * Changelog * changelog * Remove (@) * Update documentation * Remove the ancient benchmarks * Remove fixpoint lowerings
48 lines
1.1 KiB
Haskell
48 lines
1.1 KiB
Haskell
{-# OPTIONS_GHC -fno-warn-missing-signatures #-}
|
|
|
|
module TypeErrors where
|
|
|
|
-- $setup
|
|
-- >>> default ()
|
|
-- >>> :m +Polysemy
|
|
-- >>> :m +Polysemy.Output
|
|
-- >>> :m +Polysemy.Reader
|
|
-- >>> :m +Polysemy.Resource
|
|
-- >>> :m +Polysemy.State
|
|
-- >>> :m +Polysemy.Trace
|
|
-- >>> :m +Data.Maybe
|
|
|
|
|
|
--------------------------------------------------------------------------------
|
|
-- |
|
|
-- >>> :{
|
|
-- interpret @(Reader Bool) $ \case
|
|
-- Ask -> undefined
|
|
-- :}
|
|
-- ...
|
|
-- ... 'Reader Bool' is higher-order, but 'interpret' can help only
|
|
-- ... with first-order effects.
|
|
-- ...
|
|
-- ... 'interpretH' instead.
|
|
-- ...
|
|
interpretBadFirstOrder = ()
|
|
|
|
|
|
--------------------------------------------------------------------------------
|
|
-- |
|
|
-- >>> :{
|
|
-- runOutputMonoid
|
|
-- :: forall o m r a
|
|
-- . Monoid m
|
|
-- => (o -> m)
|
|
-- -> Sem (Output o ': r) a
|
|
-- -> Sem r (m, a)
|
|
-- runOutputMonoid f = runState mempty . reinterpret $ \case
|
|
-- Output o -> modify (`mappend` f o)
|
|
-- :}
|
|
-- ...
|
|
-- ... Probable cause: ...reinterpret... is applied to too few arguments
|
|
-- ...
|
|
tooFewArgumentsReinterpret = ()
|
|
|