Re: let binding ()
Subject: Re: let binding ()
Newsgroups: gmane.comp.lang.ocaml.beginners
Date: 2008-11-19 23:09:21 GMT
>
> The warning tells you that your constants are from types with
multiple values.
> The value "()" of the type "unit" is the only value of that type so
the
> pattern "()" is exhaustive (matches the only value of that type).
In
> contrast, the type "int" contains more values than just "0", so the
> pattern "0" is not exhaustive.
>
> However, constants are just a special case of this. Any patterns
that cover
> all of the values of a type will satisfy OCaml even if they do not
contain
> any identifiers to be bound:
>
> [] | _::_
>
> None | Some _
>
> let ignore _ = ()
>
> and so on.
The value of g() is []. Why doesn't [] match g()?
> > Here is an example of a value that is not matched:
> > _::_
> > let [] = g();;
> > ^^
The value of h() is 0. Why doesn't 0 match h()?
> > Here is an example of a value that is not matched:
> > 1
> > let 0 = h();;
> > ^
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch format to Traditional
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe
__,_._,___
RSS Feed