Search code examples
dhall

how to emulate Python join function in dhall?


I am new to dhall with no Haskell background. How do I convert a list of string to a single string with values separated by comma? E.g.

["a", "b", "c"] -> "a,b,c"

I tried List/fold, but couldn't figure out an idiomatic way to get rid of the extra comma.

Thanks


Solution

  • The Prelude has a Text/concatSep function, which is what you are looking for:

    let Text/concatSep = https://prelude.dhall-lang.org/Text/concatSep
    
    in  Text/concatSep "," [ "a", "b", "c" ]
    

    Here is the source code, in case you are interested in how it is implemented: