No código funciona bem como abaixo
divide :: Int -> Int -> Either String Int
divide a 0 = Left "Error with 0"
divide a b = Right (a `div` b)
O código a ser alterado
Map.adjust (divide 3) "A" $ Map.fromList [("A",3),("B",0)]
O resultado esperado deve ser:
Map.adjust (divide 3) "A" $ Map.fromList [("A",3),("B",0)]
=> Right $ Map.fromList [("A",1),("B",0)]
Map.adjust (divide 3) "B" $ Map.fromList [("A",3),("B",0)]
=> Left "Error with 0"
Ou em geral como construir uma função como:
Map.adjust:: (a -> m a) -> k -> (Map k a) -> m (Map k a)
Muito obrigado !