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 an Optional
and happens to be None
.
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
3 Likes
At the moment, you can’t. We don’t provide symbolVal
in Daml. You can define your own typeclass that has a symbolVal
instance but you’ll have to write instances for every string you need.
2 Likes
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 do
class FieldName (x : Symbol) where
fieldName : Text
Is there another way to implement your proposal that avoids using Symbol
? Or is there a way to import internal packages after all?
Regards,
Alex
1 Like
That’s a good point. I don’t think there is a good solution here atm unfortunately. We deliberately kept Symbol
hidden since it can cause problems in cross-SDK dependencies so circumventing the import restriction isn’t going to help either.
1 Like
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.
1 Like