How to write mutually recursive functions in let binding in SML?

I would like to do something like this:

fun f () =
    let
      fun a() = b()
    and
      fun b() = a()
    in
      ()
    end

where a and b are reasonable mutually recursive functions. However, this gives:

Error: syntax error: replacing  AND with  SEMICOLON

Is there any way to do this?

+5
source share
1 answer

Declaring mutually recursive functions in SML is marked with a block fun ... and ...:

fun f () =
  let
    fun a() = b()
    and b() = a() (* There is no 'fun' keyword before b() *)
  in
    ()
  end
+8
source

All Articles