Disco has strings (as List(Char)) but no easy way to turn values into strings. For example, suppose we wanted a function like
reportWidgets : N -> List(Char)
reportWidgets n = append("There are ", append(??? n, " widgets"))
There is currently nothing appropriate to put in place of ???. We could manually write our own function to turn natural numbers into strings but it would be tedious and inefficient.
I propose adding some function like format : a -> List(Char) [format a] where format is a new constraint for types that can be formatted. Alternatively we could just make it defined on all types, format : a -> List(Char), but have it return some default for types whose values can't be converted.
Disco has strings (as
List(Char)) but no easy way to turn values into strings. For example, suppose we wanted a function likeThere is currently nothing appropriate to put in place of
???. We could manually write our own function to turn natural numbers into strings but it would be tedious and inefficient.I propose adding some function like
format : a -> List(Char) [format a]whereformatis a new constraint for types that can be formatted. Alternatively we could just make it defined on all types,format : a -> List(Char), but have it return some default for types whose values can't be converted.