A monad transformer for the creation of Lists. Similar to Python's generators.

import Data.List.Class (convList) hanoi 0 _ _ _ = mempty hanoi n from to other = generate $ do yields $ hanoi (n-1) from other to yield (from, to) yields $ hanoi (n-1) other to from > convList (hanoi 3 'A' 'B' 'C') :: [(Char, Char)] [('A','B'),('A','C'),('B','C'),('A','B'),('C','A'),('C','B'),('A','B')]