packages feed

ddc-code-0.4.2.1: tetra/base/System/IO/Console.ds

module System.IO.Console 
export { write; writel; writell }
import Data.Text

import foreign abstract type
 Console  : Effect

import foreign c value
 primPutString : TextLit# -> S Console Void#
 primPutVector : [r: Region]. Vector# r Word8# -> S Console Void#

import foreign c value
 -- Get the unboxed text literal from a boxed text literal.
 -- The unboxed version is a pointer to the text data in static memory.
 takeTextLit   : TextLit -> TextLit#

where


-- | Write text to the console.
write (tt: Text): S Console Unit
 = box case tt of
        TextLit lit
         -> do  primPutString (takeTextLit lit)
                ()

        TextVec vec
         -> do  primPutVector vec
                ()

        TextApp t1 t2 
         -> do  write t1
                write t2


-- | Write text to the console with a trailing newline.
writel  (tt: Text): S Console Unit
 = do   write tt
        write "\n"


-- | Write text to the console with two trailing newlines.
writell (tt: Text): S Console Unit
 = do   write tt
        write "\n\n"