How do I convert a value of type List
to a String
in Elm?
Basically I'm looking for a function with the signature a -> String
or List -> String
.
Let's say I have a function intAverage
:
intAverage l = case l of
[] -> 0
otherwise -> Debug.log (<<SHOW_FUNCTION>> l) (List.sum l // List.length l)
Here I want to inspect the list, in order to understand what's being passed to my function. Debug.log
expects a String
which makes me look for a function with the signature a -> String
or List -> String
but I have been unsuccessful in finding such a function in the Elm package docs.
Haskell has Debug.traceShow
(which is simply an application of the function show
on the first argument of Debug.trace
) but I can't find the equivalent in Elm.
On Elm 0.19, it's been moved to Debug.toString:
For example:
> Debug.toString [1,2,3]
"[1,2,3]" : String