Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Is a Cow an Animal?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Pixel <pixel@m...>
Subject: Re: [Caml-list] Is a Cow an Animal?
Jacques Garrigue <garrigue@kurims.kyoto-u.ac.jp> writes:

[...]

> > which type "[> `Beef | `Dead_rabbit | `Dead_human] -> bool" doesn't allow 
> >   is_meat_ (food : [`Grass])
> 
> This is to avoid _too_ weak typings, which would allow for bad typos.
> The more direct solution is
>   let is_meat_ = function
>     | #meat_kind -> true
>     | #vegetable_kind -> false

ok

> > all i got is
> >  new_human : int -> ([ `Dead_human], _[< food_kind]) animal
> 
> Classical solution is eta-expansion
>   let new_human n : ([`Dead_human],  [< food_kind ]) animal =
>     new animal `Human  `Dead_human n
> should work.

/me is bad, i should have thought about this :-(

alas, it doesn't solve the real problem, it just moves it one step later:

# new_human 300;;
- : ([ `Dead_human], _[< food_kind]) animal = <obj>


thanks.
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners