how to get string from stdin using Purescript?

Viewed 34

as title says, I want to know about how to get stdin using Purescript.

I want to input string using my keyboard. that's all.

in fact, I can find some code just googling this. but nothing runs corretly. they omit import statement or complie error occurs.

It could be good if I got full code about stdin. thank you

2 Answers
module Test.Main where

import Prelude

import Effect (Effect)
import Effect.Console (log)

import Node.ReadLine (prompt, close, setLineHandler, setPrompt,  noCompletion, createConsoleInterface)

main :: Effect Unit
main = do
  interface <- createConsoleInterface noCompletion
  setPrompt "> " interface
  prompt interface
  interface # setLineHandler \s ->
    if s == "quit"
      then close interface
      else do
         log $ "You typed: " <> s
         prompt interface

Source: https://github.com/purescript-node/purescript-node-readline/blob/v6.0.0/test/Main.purs

Documentation: https://pursuit.purescript.org/packages/purescript-node-readline

Related