remove node dependencies from Prelude.newt
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
module Day1
|
module Day1
|
||||||
|
|
||||||
import Prelude
|
import Prelude
|
||||||
|
import Node
|
||||||
|
|
||||||
digits1 : List Char -> List Int
|
digits1 : List Char -> List Int
|
||||||
digits1 Nil = Nil
|
digits1 Nil = Nil
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
module Day2
|
module Day2
|
||||||
|
|
||||||
import Prelude
|
import Prelude
|
||||||
|
import Node
|
||||||
|
|
||||||
Draw : U
|
Draw : U
|
||||||
Draw = Int × Int × Int
|
Draw = Int × Int × Int
|
||||||
@@ -84,6 +85,7 @@ part2 (MkGame n parts :: rest) =
|
|||||||
|
|
||||||
run : String -> IO Unit
|
run : String -> IO Unit
|
||||||
run fn = do
|
run fn = do
|
||||||
|
putStrLn fn
|
||||||
text <- readFile fn
|
text <- readFile fn
|
||||||
case mapM parseGame (split (trim text) "\n") of
|
case mapM parseGame (split (trim text) "\n") of
|
||||||
Left err => putStrLn $ "fail " ++ err
|
Left err => putStrLn $ "fail " ++ err
|
||||||
|
|||||||
7
aoc2023/Node.newt
Normal file
7
aoc2023/Node.newt
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
module Node
|
||||||
|
|
||||||
|
import Prelude
|
||||||
|
|
||||||
|
pfunc fs : JSObject := "require('fs')"
|
||||||
|
pfunc getArgs : List String := "arrayToList(String, process.argv)"
|
||||||
|
pfunc readFile : (fn : String) -> IO String := "(fn) => (w) => MkIORes(Unit, fs.readFileSync(fn, 'utf8'), w)"
|
||||||
@@ -16,7 +16,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "keyword.newt",
|
"name": "keyword.newt",
|
||||||
"match": "\\b(data|where|class|instance|case|of|let|if|then|else|forall|∀|in|U|module|import|ptype|pfunc|infix|infixl|infixr)\\b"
|
"match": "\\b(data|where|do|class|instance|case|of|let|if|then|else|forall|∀|in|U|module|import|ptype|pfunc|infix|infixl|infixr)\\b"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "string.js",
|
"name": "string.js",
|
||||||
|
|||||||
@@ -220,7 +220,6 @@ pfunc arrayToList : {a} → Array a → List a := "(a,arr) => {
|
|||||||
}"
|
}"
|
||||||
|
|
||||||
|
|
||||||
pfunc getArgs : List String := "arrayToList(String, process.argv)"
|
|
||||||
|
|
||||||
-- for now I'll run this in JS
|
-- for now I'll run this in JS
|
||||||
pfunc lines : String → List String := "(s) => arrayToList(s.split('\\n'))"
|
pfunc lines : String → List String := "(s) => arrayToList(s.split('\\n'))"
|
||||||
@@ -297,9 +296,6 @@ pfunc unpack : String -> List Char
|
|||||||
}"
|
}"
|
||||||
|
|
||||||
|
|
||||||
ptype Dummy
|
|
||||||
pfunc fs : Dummy := "require('fs')"
|
|
||||||
pfunc readFile : (fn : String) -> IO String := "(fn) => (w) => MkIORes(Unit, fs.readFileSync(fn, 'utf8'), w)"
|
|
||||||
|
|
||||||
foldl : {A B : U} -> (B -> A -> B) -> B -> List A -> B
|
foldl : {A B : U} -> (B -> A -> B) -> B -> List A -> B
|
||||||
foldl f acc Nil = acc
|
foldl f acc Nil = acc
|
||||||
@@ -329,3 +325,7 @@ instance Ord Int where
|
|||||||
|
|
||||||
printLn : {a} {{Show a}} → a → IO Unit
|
printLn : {a} {{Show a}} → a → IO Unit
|
||||||
printLn a = putStrLn $ show a
|
printLn a = putStrLn $ show a
|
||||||
|
|
||||||
|
-- opaque JSObject
|
||||||
|
ptype JSObject
|
||||||
|
|
||||||
|
|||||||
@@ -192,7 +192,7 @@ const SAMPLES = [
|
|||||||
"Lists.newt",
|
"Lists.newt",
|
||||||
"Day1.newt",
|
"Day1.newt",
|
||||||
"Day2.newt",
|
"Day2.newt",
|
||||||
"Lib.newt",
|
"Prelude.newt",
|
||||||
"TypeClass.newt",
|
"TypeClass.newt",
|
||||||
"Combinatory.newt",
|
"Combinatory.newt",
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -220,7 +220,6 @@ pfunc arrayToList : {a} → Array a → List a := "(a,arr) => {
|
|||||||
}"
|
}"
|
||||||
|
|
||||||
|
|
||||||
pfunc getArgs : List String := "arrayToList(String, process.argv)"
|
|
||||||
|
|
||||||
-- for now I'll run this in JS
|
-- for now I'll run this in JS
|
||||||
pfunc lines : String → List String := "(s) => arrayToList(s.split('\\n'))"
|
pfunc lines : String → List String := "(s) => arrayToList(s.split('\\n'))"
|
||||||
@@ -297,9 +296,6 @@ pfunc unpack : String -> List Char
|
|||||||
}"
|
}"
|
||||||
|
|
||||||
|
|
||||||
ptype Dummy
|
|
||||||
pfunc fs : Dummy := "require('fs')"
|
|
||||||
pfunc readFile : (fn : String) -> IO String := "(fn) => (w) => MkIORes(Unit, fs.readFileSync(fn, 'utf8'), w)"
|
|
||||||
|
|
||||||
foldl : {A B : U} -> (B -> A -> B) -> B -> List A -> B
|
foldl : {A B : U} -> (B -> A -> B) -> B -> List A -> B
|
||||||
foldl f acc Nil = acc
|
foldl f acc Nil = acc
|
||||||
@@ -329,3 +325,7 @@ instance Ord Int where
|
|||||||
|
|
||||||
printLn : {a} {{Show a}} → a → IO Unit
|
printLn : {a} {{Show a}} → a → IO Unit
|
||||||
printLn a = putStrLn $ show a
|
printLn a = putStrLn $ show a
|
||||||
|
|
||||||
|
-- opaque JSObject
|
||||||
|
ptype JSObject
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user