Browse Source

fix some ocaml code highlighting

master
zapashcanon 4 weeks ago
parent
commit
4141c0b298
Signed by: zapashcanon GPG Key ID: 8981C3C62D1D28F1
  1. 6
      src/content/ocaml.md

6
src/content/ocaml.md

@ -124,7 +124,7 @@ let f_gadt : type t. t c -> t -> int =
## Small riddles
#### How to write the `val equal : unit -> unit -> bool` function ?
<h4>How to write the <code class="language-ocaml">val equal : unit -> unit -> bool</code> function ?</h4>
When I teach OCaml to some people, after some time, I like to ask them this question. Here are the answer I usually get.
@ -133,7 +133,7 @@ When I teach OCaml to some people, after some time, I like to ask them this ques
<code class="language-ocaml">let equal x y = if x = y then true else false</code>
</details>
Come on ! First you should write it `let equal x y = x = y`. But more importantly, there's no need to test for equality, there's only one inhabitant for the `unit` type, so it's always `true`. Try again !
Come on ! First you should write it <code class="language-ocaml">let equal x y = x = y</code>. But more importantly, there's no need to test for equality, there's only one inhabitant for the `unit` type, so it's always `true`. Try again !
<details>
<summary>Second answer:</summary>
@ -147,7 +147,7 @@ Well, `dune` will make the compiler shrill because of unused variables. Let's tr
<code class="language-ocaml">let equal _ _ = true</code>
</details>
Better, but this has the signature `val equal : 'a -> 'b -> bool` (and the previous answer too). How can we fix this ?
Better, but this has the signature <code class="language-ocaml">val equal : 'a -> 'b -> bool</code> (and the previous answer too). How can we fix this ?
<details>
<summary>Fourth answer:</summary>

Loading…
Cancel
Save