Text.split & Sets

I know this will certainly go in the realm of “no Text comparisons”, but I want to express a grievance.

I have a spec "The purpose member is an unordered set of unique space-separated tokens. The allowed values are the icon purposes. "

I’d argue this spec is set up kind of like trash, where it just shouldn’t be space-separated, and could be an array in this case (for JSON). I can create an enum and make a show function that merges these into a string and then use Prelude/Text/concatMapSep " " Purpose show (xs : List Purpose) and get the desired output. What I’d like is the desired input. So the ability to split on " " (or perhaps “,” in other cases), map from Text -> Enum, and do List a -> Set a. Because I can’t do this, my field’s value is now Some Text which is worse than Some (Set Enum).

Again, this is probably a bad spec but, tautologically, it is what it is nonetheless. What do other users do with strange cases like this? Parse with Dhall, use another language to split the string and then re-Dhall that result?

1 Like

I think the answer to your question is that usually conversions from another configuration format to Dhall are implemented outside of Dhall (e.g. an executable using Dhall’s Haskell API). To be sure, though, I’d need to better understand why you are trying to parse another configuration format using Dhall.