Zulip Chat Archive

Stream: lean4

Topic: accessing MetaM from IO


Arthur Paulino (Dec 20 2021 at 00:00):

Suppose I have a function A whose return type is IO String and another function B whose return type is MetaM String.
Is there a way to call let x : String ← B <args> inside A?
Detail: I have an instance of Environment as an input of A that can be used, if needed.
C.C.: @Tomas Skrivan

Tomas Skrivan (Dec 20 2021 at 00:06):

I would phrase the question a bit differently. Given e : Environment can you initialize fresh state of MetaM and execute some functions in MetaM like whnf and then obtain the value i.e. turn for example MetaM String to Option String (none if some exception happened)?

Arthur Paulino (Dec 20 2021 at 00:07):

That's indeed a better way to put it

Mac (Dec 20 2021 at 00:57):

@Arthur Paulino both MetaM and CoreM have a lot of settings that you may wish to configure, but here is the most minimal example:

#eval show IO _ from do
  let env : Environment := arbitrary
  let act : MetaM PUnit := pure ()
  Prod.fst <$> act.run'.toIO {} {env}

Last updated: Dec 20 2023 at 11:08 UTC