かなりシンプルに実装できた。よい子は絶対にマネしないでね! import qualified Data.IntMap as M import Control.Monad.Trans.Free import Control.Monad.Trans newtype Label = LabelId Int deriving (Eq, Ord) data Labeling a = Label (Label -> a) | Goto Label -- deriving Functorがあれば不要 instance Functor Labeling where fmap f (Label g) = Label (f . g) fmap f (Goto l) = Goto l type GotoT = FreeT Labeling label :: Monad m => GotoT m Label la