This is using Free and liftF from Control.Monad.Free, but for the sake of equivalence with the F# example, here’s a definition that can be used in place of the import Control.Monad.Free line in the above code.