
5 Jun
2013
5 Jun
'13
11:28 p.m.
Hi Brent,
I would do this using an associated type, like so:
class Turtlish t where type TState t :: * pic :: t -> Dia state :: t -> TState t move :: TState t -> t -> t (>>>),(+++) :: t -> t -> t x >>> y = x +++ move (state x) y
Bingo. Just what I needed. But is this a Haskellish thing to do or am I showing my C++ background by even wanting something like this? Anyway, for the sake of any future googlers, I needed {-# LANGUAGE TypeFamilies #-} and completed the instance with: instance Turtlish TurtWorld where type TState TurtWorld = TurtState ... Thanks, Adrian.