module MAC.Core
(
Res (MkRes,unRes)
, labelOf
, MAC (MkMAC)
, runMAC
, ioTCB
)
where
import Control.Applicative
newtype Res l a = MkRes {unRes :: a}
labelOf :: Res l a -> l
labelOf _res = undefined
newtype MAC l a = MkMAC (IO a)
instance Functor (MAC l) where
fmap f (MkMAC io) = MkMAC (fmap f io)
instance Applicative (MAC l) where
pure = MkMAC . return
(<*>) (MkMAC f) (MkMAC a) = MkMAC (f <*> a)
instance Monad (MAC l) where
return = pure
MkMAC m >>= k = ioTCB (m >>= runMAC . k)
ioTCB :: IO a -> MAC l a
ioTCB = MkMAC
runMAC :: MAC l a -> IO a
runMAC (MkMAC m) = m