searchPredicate :: String -> String -> Bool
searchPredicate = \_ _ -> False
seems to make no difference. searchPredicate = isPrefixOf
Patching and recompiling with this patch[1] mentioned here[2] seems to fix the issue. routine =
case Just (0,0) of
Nothing -> Nothing
Just start -> case landLeft 2 start of
Nothing -> Nothing
Just first -> case landRight 2 first of
Nothing -> Nothing
Just second -> landLeft 1 second
becomes (using some 'do' syntactic sugar): routine = do
start <- return (0,0)
first <- landLeft 2
second <- landRight 2 first
landLeft 1 second
Checking for Nothing is taken care of 'automatically' and if any of start, first, second or (landLeft 1 second) are equal to Nothing routine is equal to Nothing too.
I was inspired by posts like this one [1] to give the free monad a spin and after ~300 lines i'm almost done. But then I found other posts that talk about free and cofree [2] that I still can't really understand so I guess there still is some room for improvement.
[1] http://www.haskellforall.com/2012/06/you-could-have-invented... [2] http://dlaing.org/cofun/posts/free_and_cofree.html