Skip to content

Instantly share code, notes, and snippets.

@neongreen
Last active May 14, 2020 16:19
Show Gist options
  • Save neongreen/5cfd0a605e1e82b47f94097e79e1b26f to your computer and use it in GitHub Desktop.
Save neongreen/5cfd0a605e1e82b47f94097e79e1b26f to your computer and use it in GitHub Desktop.
#!/usr/bin/env stack
-- stack --resolver lts-13.26 script --package purescript --extra-dep aeson-1.4.7.1 --extra-dep serialise-0.2.2.0 --extra-dep cborg-0.2.2.0 --extra-dep happy-1.19.9 --extra-dep language-javascript-0.7.0.0 --extra-dep network-3.0.1.1 --extra-dep these-1.0.1 --extra-dep semialign-1 --extra-dep assoc-1.0.1 --extra-dep bifunctors-5.5.7 --extra-dep th-abstraction-0.3.2.0 --extra-dep time-compat-1.9.3 --package text --optimize
{-# LANGUAGE LambdaCase #-}
import Data.List
import Data.List.NonEmpty (toList)
import qualified Data.Text.IO as T
import Language.PureScript.CST.Errors
import Language.PureScript.CST.Parser
import System.Environment
import System.Exit
main = do
fp <- getArgs >>= \case
[fp] -> pure fp
_ -> die "No input file specified"
file <- T.readFile fp
case parse file of
Right _ -> pure ()
Left errs ->
die
$ unlines
$ ([fp] ++)
$ intersperse ""
$ map ((" - " ++) . prettyPrintError)
$ toList errs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment