
25 Nov
2021
25 Nov
'21
5:10 p.m.
Hi, This isn’t homework! I’ve been staring at this for several hours - and that usually works. I also tried typed holes to no avail. I thinks it is quite simple really but I’ve gone past seeing it! I have data Expr a = Var a | Add (Expr a) (Expr a) and would like to write convert :: Expr (Maybe a) -> Maybe (Expr a) which returns Nothing if there is an occurrence of Nothing inside the input expression e, otherwise it returns Just e', where e' is a new expression where the internal values of type a are not wrapped in Just. You should use the functionality of the Maybe monad to implement the convert function. Thanks Mike