Skip to content

Instantly share code, notes, and snippets.

Created December 23, 2012 18:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/4364920 to your computer and use it in GitHub Desktop.
Save anonymous/4364920 to your computer and use it in GitHub Desktop.
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
import Control.Monad.State
import Control.Monad.Trans
-- Stuff from haskeline. MonadException is something that haskeline requires for whatever reason.
class MonadIO m => MonadException m
newtype InputT m a = InputT (m a) deriving (Monad, MonadIO)
myInputFunc :: MonadException m => InputT m (Maybe String)
myInputFunc = undefined
-- Stuff from my own transformer. This requires that m be MonadIO because it needs to store state to disk
data FitState = FitState
newtype FitStateT m a = FitStateT (StateT FitState m a) deriving (Monad, MonadTrans)
myFitStateFunc :: MonadIO m => FitStateT m ()
myFitStateFunc = undefined
-- End result, which was not ideal.
myMainRoutineFunc :: (MonadException m, MonadIO m) => FitStateT (InputT m) ()
myMainRoutineFunc = do
myFitStateFunc
lift $ myInputFunc
return ()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment