{-# LANGUAGE DataKinds #-}
{-# LANGUAGE ExistentialQuantification #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE Safe #-}
module Control.Eff.Operational ( Program (..)
, singleton
, runProgram
) where
import Control.Eff
data Program instr v where
Singleton :: instr a -> Program instr a
singleton :: (Member (Program instr) r) => instr a -> Eff r a
singleton = send . Singleton
runProgram :: forall f r a. (forall x. f x -> Eff r x) -> Eff (Program f ': r) a -> Eff r a
runProgram advent = handle_relay return h
where
h :: forall v. Program f v -> (v -> Eff r a) -> Eff r a
h (Singleton instr) k = advent instr >>= k