#haskell help !
Using a `lookup` inside a State monad function .
I can't do
lu <- lookup place maze
I have to handle Nothing myself after
let lu = lookup place maze
Q - What's the idiomatic way?
---
visit :: [(String,[String])] -> String -> State [String] ()
visit maze place = do
s <- get
if elem place s
then do
return ()
else do
put (place : s)
let lu = lookup place maze
case lu of
Nothing -> return ()
Just ns -> forM_ ns (visit maze)