How is the newline, tab characters represented in purescript?

560 views Asked by At

For eg. How do I print out something like this:

showEntry entry = entry.lastName ++ "\t" ++
                  entry.firstName ++ "\t" ++
                  entry.phone
print(showEntry {lastName: 'Doe', firstName: 'John', phone: '555-555-5555'})

This just prints out Doe\tJohn\t555-555-5555.

1

There are 1 answers

0
erisco On BEST ANSWER

The question was based on an old version of the language and associated tools. Nowadays, this is what you can do.

Use log from purescript-console (https://pursuit.purescript.org/packages/purescript-console/4.2.0/docs/Effect.Console#v:log).

> import Effect.Console
> log "Hello\tSailor!"
Hello   Sailor
unit

>

The REPL (purs repl) uses show implicitly to encode values as strings. To get around this, one can use the log effect (as Phil Freeman mentioned in his comment, though there is nothing unsafe about using log).