1

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

2 Answers 2

1
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

Sign up to request clarification or add additional context in comments.

Comments

0

Here is a package for reading from stdin, but it might not work the way you expect with keyboard input.

https://pursuit.purescript.org/packages/purescript-node-streams-aff

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.