How are newlines, tabs represented in purescript?

For example, How to print something like this:

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

      

It just prints Doe\tJohn\t555-555-5555

.

+3


source to share


2 answers


Using

\n\



Change to

showEntry entry = entry.lastName \n\ 
                  entry.firstName \n\
                  entry.phone

      

+1


source


The question was based on an old version of the language and related tools. This is currently 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

>

      

REPL (purs repl) is implicitly used show

to encode values ​​as strings. To get around this, the log effect can be used (as Phil Freeman mentioned in his comment, although there is nothing unsafe to use log

).

0


source







All Articles