Version française
Home     About     Download     Resources     Contact us    
Browse thread
RE: [Caml-list] Turning off type-checking
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: John Max Skaller <skaller@o...>
Subject: Re: [Caml-list] Turning off type-checking
Markus Mottl wrote:

>
>---------------------------------------------------------------------------
>let model meal_d1 =
>  let satisfaction_c1 =
>    (match meal_d1 with
>    | TapirSoup spiced_d1 ->
>        (match spiced_d1 with
>        | True -> Low
>        | False -> High)
>    | Pizza (_, spiced_d1, topping_d1) ->
>        let satisfaction_c1 =
>          (match spiced_d1 with
>          | True ->
>              (match topping_d1 with
>              | Cheese sort_d1 ->
>                  (match sort_d1 with
>                  | Gorgonzola -> Low
>                  | Mozzarella -> High)
>              | _ -> High)
>          | False -> Low) in
>        Very satisfaction_c1
>    | WienerSchnitzel _ -> Low) in
>  Very satisfaction_c1
>---------------------------------------------------------------------------
>
>If there are, say, mappings from 100 to 100 variables and thousands of
>deeply structured sample values (a "real-world" problem), the models
>can look quite terrifying.
>

Hmm. The standard programmers trick here is to lift out the
nested components, at the cost of passing the environment as
arguments: if you type the arguments, it short circuits inference.

BTW: you can encode the "Very" recursion as an integer.
For some models .. eg the model is a grammar and the
data is a program with output a parse tree .. this optimisation
isn't useful .. but in the 'real' world a lot of data is scalar
rather than recursive.


-- 
John Max Skaller, mailto:skaller@ozemail.com.au
snail:10/1 Toxteth Rd, Glebe, NSW 2037, Australia.
voice:61-2-9660-0850




-------------------
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