mirror of
https://github.com/polysemy-research/polysemy.git
synced 2024-12-12 13:06:18 +03:00
27 lines
454 B
Haskell
27 lines
454 B
Haskell
{-# LANGUAGE DataKinds #-}
|
|
{-# LANGUAGE TemplateHaskell #-}
|
|
|
|
import Test.Inspection
|
|
import Control.Monad.Discount
|
|
import Data.OpenUnion
|
|
import TRYAGAIN hiding (main)
|
|
|
|
|
|
main :: IO ()
|
|
main = pure ()
|
|
|
|
go :: Eff '[State Int] Int
|
|
go = do
|
|
n <- send (Get id)
|
|
if n <= 0
|
|
then pure n
|
|
else do
|
|
send $ Put (n-1) ()
|
|
go
|
|
|
|
countDown :: Int -> Int
|
|
countDown start = fst $ run $ runState start go
|
|
|
|
inspect $ 'countDown `hasNoType` ''SNat
|
|
|