Is there a way to select the head of a list of an optional term while transforming such that if it exists you get the element else you get an empty string or the result of calling the function doesn't return anything? For example, if you had the ADT:
data TakeAction = set(list[OptVal] opt, str expandedId, NumVal numVal)
which corresponded with the syntax:
syntax TakeAction = set: SET OptVal? EXPANDEDID NumVal
and you try to write a function like so:
public str prettyTakeAction(TakeAction::set(list[OptVal] opt, str expandedId, NumVal numVal)) = "SET <prettyOptVal(opt)><expandedId> = <prettyNumVal(numVal)>";
where
public str prettyOptVal(OptVal::optVal()) = "OPTIONAL"
When I try this out, If I omit the OPTIONAL
, I get an error, for example
SET a = 8
will throw an error, while SET OPTIONAL a = 3
will work