<div dir="ltr"><span style="font-size:13px;line-height:19.5px">hello,</span><div style="font-size:13px;line-height:19.5px"><br></div><div style="font-size:13px;line-height:19.5px">I am starting with Haskell and trying some little exercices on my own. I successfully implemented a reverse polish notation evaluator and I want to improve it a little using <b>Maybe</b></div><div style="font-size:13px;line-height:19.5px"><b><br></b></div><div style="font-size:13px;line-height:19.5px">All i want is to implement  a function that can returned available functions according to its string name</div><div style="font-size:13px;line-height:19.5px">i.e return (+) when gived "+"</div><div style="font-size:13px;line-height:19.5px">I also want to return Nothing if the operation is not available (not implemented yet). </div><div style="font-size:13px;line-height:19.5px">So my function should Maybe return a (float -> float -> float)</div><div style="font-size:13px;line-height:19.5px"><br></div><div style="font-size:13px;line-height:19.5px">My current implementation is </div><div style="font-size:13px;line-height:19.5px"><br></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px;font-size:13px;line-height:19.5px"><div>operation :: String -> Maybe Float -> Float -> Float</div><div>operation op </div><div>   | op == "+" = Just (+)</div><div>   | op == "-" = Just (-)</div><div>   | op == "*" = Just (*)</div><div>   | op == "/" = Just (/)</div><div>   | otherwise = Nothing</div></blockquote><div style="font-size:13px;line-height:19.5px"><br></div><div style="font-size:13px;line-height:19.5px">but it failed to compile with the following error : </div><div style="font-size:13px;line-height:19.5px"><br></div><div style="font-size:13px;line-height:19.5px"><div>rpn.hs:64:18:</div><div>    Couldn't match expected type `Maybe Float -> Float -> Float'</div><div>                with actual type `Maybe a0'</div><div>    In the expression: Nothing</div><div>    In an equation for `operation':</div><div>        operation op</div><div>          | op == "+" = Just (+)</div><div>          | op == "-" = Just (-)</div><div>          | op == "*" = Just (*)</div><div>          | op == "/" = Just (/)</div><div>          | otherwise = Nothing</div></div><div style="font-size:13px;line-height:19.5px"><br></div><div style="font-size:13px;line-height:19.5px"><br></div><div style="font-size:13px;line-height:19.5px">I don't understand the error :( Do I have to explicitly type the Nothing return ? </div><div style="font-size:13px;line-height:19.5px"><br></div><div style="font-size:13px;line-height:19.5px">Could you guide me to a solution or explain me what I am doing wrong, please ?</div><div style="font-size:13px;line-height:19.5px"><br></div><div style="font-size:13px;line-height:19.5px">Thanks in advance</div><div style="font-size:13px;line-height:19.5px"><br></div><div style="font-size:13px;line-height:19.5px">Olivier</div></div>