Skip to content

Commit

Permalink
Prep repo for breaking changes (#31)
Browse files Browse the repository at this point in the history
* Update CI node, actions versions; enforce formatting

* Format via purs-tidy
  • Loading branch information
JordanMartinez authored Jul 20, 2023
1 parent fbe80a9 commit 446c753
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 17 deletions.
12 changes: 9 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,16 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- uses: purescript-contrib/setup-purescript@main
with:
purescript: "unstable"
purs-tidy: "latest"

- uses: actions/setup-node@v2
- uses: actions/setup-node@v3
with:
node-version: "14"
node-version: "lts/*"

- name: Install dependencies
run: |
Expand All @@ -33,3 +34,8 @@ jobs:
run: |
bower install
npm run-script test --if-present
- name: Check Formatting
if: runner.os == 'Linux'
run: |
npx purs-tidy check src
17 changes: 9 additions & 8 deletions src/Node/ReadLine.purs
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ historySize = opt "historySize"
-- |
-- | This function takes the partial command as input, and returns a collection of
-- | completions, as well as the matched portion of the input string.
type Completer
= String
type Completer =
String
-> Effect
{ completions :: Array String
, matched :: String
}
{ completions :: Array String
, matched :: String
}

-- | Builds an interface with the specified options.
createInterface
Expand All @@ -69,15 +69,16 @@ createInterface
-> Options InterfaceOptions
-> Effect Interface
createInterface input opts = createInterfaceImpl
$ options $ opts
<> opt "input" := input
$ options
$ opts
<> opt "input" := input

-- | Create an interface with the specified completion function.
createConsoleInterface :: Completer -> Effect Interface
createConsoleInterface compl =
createInterface stdin
$ output := stdout
<> completer := compl
<> completer := compl

-- | A completion function which offers no completions.
noCompletion :: Completer
Expand Down
11 changes: 5 additions & 6 deletions test/Main.purs
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,15 @@ import Prelude
import Effect (Effect)
import Effect.Console (log)

import Node.ReadLine (prompt, close, setLineHandler, setPrompt, noCompletion, createConsoleInterface)
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
if s == "quit" then close interface
else do
log $ "You typed: " <> s
prompt interface

0 comments on commit 446c753

Please sign in to comment.