[Haskell-beginners] Monad question
Kim-Ee Yeoh
ky3 at atamo.com
Thu Nov 25 18:55:42 UTC 2021
Hi Mike,
On Fri, Nov 26, 2021 at 12:12 AM mike h <mike_k_houghton at yahoo.co.uk> wrote:
>
> I have
> data Expr a = Var a | Add (Expr a) (Expr a)
>
> and would like to write
>
> convert :: Expr (Maybe a) -> Maybe (Expr a)
With the requisite setup, convert has a one word definition. But more on
that later.
Yehoshua has already given you a nudge in the right direction. Others will
surely chime in if you get stuck grinding out something the compiler will
type check.
What we could discuss is higher level. Where would use this convert
function? What utility could you obtain from it?
>
> 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
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
--
-- Kim-Ee
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20211126/d812f699/attachment.html>
More information about the Beginners
mailing list