Zulip Chat Archive

Stream: lean4

Topic: ReduceEval and String


Alex Keizer (Sep 21 2023 at 16:23):

I am writing some meta-code where I want to turn an Expr describing a String into an actual String object.
I initially thought reduceEval was what I want, but it seems to only work for string literals:

import Qq
open Qq Lean.Meta

#eval (reduceEval q("a") : MetaM String) -- "a"

/- reduceEval: failed to evaluate argument
    "a" ++ "b" -/
#eval (reduceEval q("a" ++ "b") : MetaM String)

Is this by design or a bug?

Alex J. Best (Sep 21 2023 at 16:28):

I don't know about reduceEval but you can do

#eval (evalExpr String q(String) q("a" ++ "b") : MetaM String)

Alex Keizer (Sep 21 2023 at 16:41):

Thanks! That indeed works for my minimized example, but for my actual code evalExpr throws an incomplete case error

Alex J. Best (Sep 21 2023 at 16:55):

What is in your actual code that causes that?


Last updated: Dec 20 2023 at 11:08 UTC