Turning a compile-time symbol into a run-time Text
- Alexander_BernauerOP 3
Hi
as a follow-up to (1) I was wondering, how can I get a runtime string from a compile time symbol such as
@"bar". I need this for error reporting in cases where the field is anOptionaland happens to beNone.In Haskell I believe the answer is symbolVal. But I am not allowed to import GHC.TypeLits. What is the DAML way of doing this?
CC: @Sofia_Faro, maybe you know?
Regards,
Alex(1) Generating record update functions to be used as parameters - #3 by Sofia_Faro
- cocreature 2
At the moment, you can’t. We don’t provide
symbolValin Daml. You can define your own typeclass that has asymbolValinstance but you’ll have to write instances for every string you need. - Alexander_Bernauer 1
Hi @cocreature,
it seems this is not possible either, because I cannot import
GHC.Types, this being considered an internal module. Here is what I am trying to doclass FieldName (x : Symbol) where fieldName : TextIs there another way to implement your proposal that avoids using
Symbol? Or is there a way to import internal packages after all?Regards,
Alex - cocreature 1
That’s a good point. I don’t think there is a good solution here atm unfortunately. We deliberately kept
Symbolhidden since it can cause problems in cross-SDK dependencies so circumventing the import restriction isn’t going to help either. - Luciano 1
I know this won’t answer your question directly, but have you looked at DA.Stack? It provides some introspection ability, and although you won’t be able to access the AST, at least you can get information about the file/line numbers when debugging. It got snuck in to the SDK, not quite sure when.