Skip to content

Commit

Permalink
[remove] dead code in the stream example.
Browse files Browse the repository at this point in the history
  • Loading branch information
ymdryo committed Oct 27, 2024
1 parent 3c7ee1d commit 55e5da5
Showing 1 changed file with 2 additions and 27 deletions.
29 changes: 2 additions & 27 deletions heftia-effects/Example/Stream/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,43 +7,18 @@ module Main where

import Control.Arrow ((>>>))
import Control.Monad (forever, void, when)
import Control.Monad.Hefty (
Eff,
interpret,
liftIO,
raiseAllH,
(&),
type (<:),
type (<<|),
type (<|),
type (~>),
)
import Control.Monad.Hefty (Eff, liftIO, raiseAllH, type (<:), type (<|))
import Control.Monad.Hefty.Concurrent.Parallel (runParallelIO)
import Control.Monad.Hefty.Concurrent.Stream (Machinery (Unit), runMachinery, runMachineryIO)
import Control.Monad.Hefty.Concurrent.Timer (Timer, runTimerIO, sleep)
import Control.Monad.Hefty.Except (runThrow, throw)
import Control.Monad.Hefty.Input (Input, input)
import Control.Monad.Hefty.Output (Output, output)
import Control.Monad.Hefty.Resource (Resource, bracket_, runResourceIO)
import Control.Monad.Hefty.Resource (bracket_, runResourceIO)
import Control.Monad.Hefty.Unlift (runUnliftIO)
import Control.Monad.IO.Class (MonadIO)
import Data.Foldable (for_)

data SomeIOResource a where
ReadResource :: SomeIOResource Int
WriteResource :: Int -> SomeIOResource ()

runSomeResource
:: (Resource <<| eh, IO <| ef)
=> Eff eh (SomeIOResource ': ef) ~> Eff eh ef
runSomeResource m = bracket_
(liftIO $ putStrLn "Acquiring resource")
(liftIO $ putStrLn "Releasing resource")
do
m & interpret \case
ReadResource -> error "just dummy"
WriteResource _ -> error "just dummy"

{- | In reality, this 'throw' operates independently of @bracket@...
because 'runThrow' functions under the semantics of pure algebraic effects,
it operates independently without interfering with 'IO'-level exceptions.
Expand Down

0 comments on commit 55e5da5

Please sign in to comment.