Skip to content

Commit

Permalink
Use #show_type
Browse files Browse the repository at this point in the history
  • Loading branch information
Cuihtlauac ALVARADO committed Nov 27, 2023
1 parent 8a0ed2e commit 86c04db
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions data/tutorials/language/0it_06_imperative.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,15 +146,12 @@ In contrast to references, there is no special syntax to dereference a mutable r

In OCaml, references are records with a single mutable field:
```ocaml
# #show ref;;
external ref : 'a -> 'a ref = "%makemutable"
# #show_type ref;;
type 'a ref = { mutable contents : 'a; }
```

The type `'a ref` is a record with a single field `contents` which is marked with the `mutable` keyword.

The line `external ref : 'a -> 'a ref = "%makemutable"` means the function `ref` is not written in OCaml, but that is an implementation detail we do not care about in this tutorial. If interested, check the [Calling C Libraries](/docs/calling-c-libraries) tutorial to learn how to use the foreign function interface.

Since references are single field records, we can define functions `assign` and `deref` using the mutable record field update syntax:
```ocaml
# let assign a x = a.contents <- x;;
Expand Down

0 comments on commit 86c04db

Please sign in to comment.