Skip to content

Instantly share code, notes, and snippets.

@yonta
Created August 2, 2023 20:51
Show Gist options
  • Save yonta/136968f8316d26f8f050e22eee385dc6 to your computer and use it in GitHub Desktop.
Save yonta/136968f8316d26f8f050e22eee385dc6 to your computer and use it in GitHub Desktop.
Loop Cell
datatype 'a cell = CELL of 'a * 'a cell option ref
val cell = CELL (1, ref NONE)
(* val cell = CELL (1, ref NONE) : int cell *)
val cellRef = ref (SOME cell)
(* val cellRef = ref (SOME (CELL (1, ref NONE))) : int cell option ref *)
cellRef := SOME (CELL (1, cellRef))
(* val it = () : unit *)
cellRef
(*
val it =
ref
(SOME
(CELL
(
1,
ref
(SOME
(CELL
(
1,
ref
(SOME
(CELL
(
1, ref (SOME (CELL (1, ref (SOME (CELL (..., ...))))))
)))
)))
)))
: int cell option ref
*)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment