index 15f2d2a..d718c9a 100644 (file)
@@ -261,12 +261,14 @@ And you won't have any of the kinds of difficulties we're discussing here with t

By the way, this issue about not-enough-polymorphism doesn't arise in Haskell. Here are the Church numerals:

-    > data Church a = Church ((a->a)->a->a)
-    > let { zero::Church a; zero = Church (\s z -> z); one::Church a; one = Church (\s z -> s z); succ n = case n of { Church n -> Church (\s z-> s (n s z)) } }
+    > type Church a = (a -> a) -> a -> a
+    > let { zero :: Church a; zero = \s z -> z; one :: Church a; one = \s z -> s z; succ n = \s z-> s (n s z) }
> let two = succ one
-    > case two of { Church n -> n ('S':) "0" }
+    > two ('S':) "0"
"SS0"
> :t two
-    two :: Church a
+    two :: (a -> a) -> a -> a
+    > two (1+) 0
+    2

The reason that OCaml has trouble here where Haskell doesn't has to do with some fundamental differences between their type systems, that we haven't yet explored. (Specifically, it has to do with the fact that OCaml has *mutable reference cells* in its type system, and this obliges it to place limits on where it generalizes type variables, else its type system becomes inconsistent.)
{"ft_lang_label":"__label__en","ft_lang_prob":0.9335084,"math_prob":0.848509,"size":1009,"snap":"2021-04-2021-17","text_gpt3_token_len":314,"char_repetition_ratio":0.14626865,"word_repetition_ratio":0.06278027,"special_character_ratio":0.38057482,"punctuation_ratio":0.1495327,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9642835,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-04-18T08:17:51Z\",\"WARC-Record-ID\":\"<urn:uuid:938be329-647c-4083-870e-88524bfd26ed>\",\"Content-Length\":\"10869\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:4c0e6efc-ee9a-4879-abd8-63d23b51b85f>\",\"WARC-Concurrent-To\":\"<urn:uuid:f6d04bac-6bcc-4c33-9eea-6228433d356a>\",\"WARC-IP-Address\":\"45.79.164.50\",\"WARC-Target-URI\":\"http://lambda.jimpryor.net/git/gitweb.cgi?p=lambda.git;a=blobdiff;f=exercises/assignment5_hint4.mdwn;h=d718c9a7c01c5af843c731b43ff08616bc1c6cc2;hp=15f2d2a4d1e928093a6fe3b2ccb27b92058e5478;hb=a7f15a6a8100c10bde1cf7b97a02660a3d00b9d9;hpb=56341740e1fdfbee34cc0d1bf0dc893e18f447fa\",\"WARC-Payload-Digest\":\"sha1:OTRW2ENIICH6EX4BD5SBB34PS6MIAOMQ\",\"WARC-Block-Digest\":\"sha1:UZYLELISHTCK7Q4FR73MN4N7U6VHNS4Z\",\"WARC-Identified-Payload-Type\":\"application/xhtml+xml\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-17/CC-MAIN-2021-17_segments_1618038469494.59_warc_CC-MAIN-20210418073623-20210418103623-00419.warc.gz\"}"}