<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Fri, Mar 27, 2015 at 4:44 AM, Shishir Srivastava <span dir="ltr"><<a href="mailto:shishir.srivastava@gmail.com" target="_blank">shishir.srivastava@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Sorry, but I still have some grudges so to say with the way 'Maybe' is defined. <div><br></div><div>By definition '<b>Maybe</b>' takes a type parameter which I will denote here as '<b>tp</b>' for the sake of clarity like below - <div><br></div><div><span style="font-family:monospace,monospace;font-size:12.8000001907349px">data Maybe tp = Just tp | Nothing</span><br><div><br></div><div>Therefore '<b>tp</b>' is not representing a value perse such as '3' or 'XYZ' etc but a data type such as '<b>Int</b>', '<b>Char</b>' etc. </div></div><div><br></div><div>But when we have to create a data type of '<b>Maybe</b>' we write '<b>Just 3</b>' and not '<b>Just Int</b>' or '<b>Just Char</b>' which is how it's defined in the definition (i.e. '<b>Just tp</b>' ) . </div><div><br></div><div>It is this discrepancy in definition and the actual value creation which is slightly troubling me.</div></div></div></blockquote><div><br></div><div>This was already explained, all be it in passing.</div><div><br></div><div>Maybe Int is a type. Just and and Nothing are functions. Nothing takes no arguments. Just takes a single argument of the type given. There IS no type that Just Int would represent. There are only the two types Int and Maybe Int. 3 is of type Int. Just 3 is of type Maybe Int. Nothing is of type Maybe Int as well.</div><div><br></div><div>Going back to the notion of "type plus error value", Int is the type, and Maybe Int is the type with an error value, the error value being Nothing.</div><div><br></div><div>It might be educational to look at a second example. Try the Either types, which are sometimes used in a manner similar to the Maybe types. But instead of Nothing to indicate "an error occurred", you have Left tp to indicate that an error occurred using the value of tp to provide information about the error.</div></div></div></div>