I do not know how the List ListT transformer should be used. For example, how this simple task should be performed:
ListT
backtrack :: ListT IO () backtrack = do x <- lift getLine a <- x lift $ print a
And what type of function should be?
This is not the task I'm trying to accomplish (I know how to solve this problem using many other methods), I just want to know how to use ListT to perform such tasks.
Is this what you tried to do?
import Control.Monad.List backtrack :: ListT IO () backtrack = do x <- ListT getLine lift $ print x
Example run in GHCi:
*Main> runListT backtrack foo 'f' 'o' 'o' [(), (), ()]
You should look at ListT done right and the LogicT countdown. In particular, interleave in logic handles infinity better.