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.
Edit: This is no longer true as of Elm version 0.19. See the other answer to this question.
The toString was what I was looking for, but couldn't find.
toString :: a -> String
I found it in the Basics-package: toString documentation
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With