Skip to content

format primitive for turning values into pretty-printed strings #411

@byorgey

Description

@byorgey

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions