-- learnes to move the tower of hanoi from one pile to another
data Disc = D0 | D Disc deriving (Show)
data Action = NOOP | MV Disc Peg Peg Action deriving (Show)
data Peg = PegA | PegB | PegC deriving (Show)

hanoi :: Disc -> Peg -> Peg -> Peg -> Action -> Action
hanoi D0 src aux dst s        = MV D0 src dst s
hanoi (D D0) src aux dst s    = MV D0 aux dst 
                                 (MV (D D0) src dst 
                                   (MV D0 src aux s))
hanoi (D(D D0)) src aux dst s = MV D0 src dst
                                 (MV (D D0) aux dst
                                   (MV D0 aux src
                                     (MV (D(D D0)) src dst
                                       (MV D0 dst aux
                                         (MV (D D0) src aux
                                           (MV D0 src dst s ))))))

