>>522
それ Haskellなら

module State (State, next) where
class State s where
 next :: s -> e -> s

module StateA (StateA(), stateA) where
data StateA = StateA Integer

sateteA = StateS

instance State StateA where
next (StateA i) e = f i e
  where
   f = ...


みたいにすれば良いんじゃね?