Open DonaldKellett opened 5 years ago
Or are such Kata (requiring certain built-ins to be hidden) highly discouraged and only kept as legacy content?
I don't think so. I liked "Fix it". It's just sad that we need to test that users don't use the builtin.
But it depends because I don't think we need hundreds of kata to implement builtin functions from different languages.
Anyways, I'll try to describe how PureScript runner works (it's very simple).
PureScript runner uses pulp to run tests and uses psc-package to manage packages.
Here's what happens when PureScript code is submitted.
solution
and preloaded
goes under src/
test
goes under test/
pulp test
Filenames are derived from module declarations.
If we can come up with some module like Test.Codewars.BlackList
, we should be able to make that available by placing it in the right place.
Do you know any packages that we can use?
If you want to start experimenting, you should be able to just create a new PureScript project locally for it because we don't really do anything special (we just use spec-discover
and specify the reporter; and those should be irrelevant).
The most up to date psc-package.json
is:
{
"name": "codewars-purescript",
"set": "psc-0.12.2-20190119",
"source": "https://github.com/purescript/package-sets.git",
"depends": [
"prelude",
"console",
"effect",
"bigints",
"rationals",
"spec",
"spec-discovery",
"spec-quickcheck"
]
}
I haven't deployed this one yet, but I'm planning to tonight.
Do you know any packages that we can use?
IIRC Haskell recently added the parsec
parser library? The description for purescript-parsing
is "A parser combinator library based on Haskell's Parsec" - perhaps we could use this to implement our Test.Codewars.BlackList
for PureScript?
Possible alternatives include:
purescript-string-parsers
- claims to be simpler and faster than purescript-parsing
provided that the input is known to be a string (which is probably the case if we're just reading from /home/codewarrior/solution.txt
)Data.String.Regex
is already available on Codewars) I reckon going this route will be a right pain in the ass though 😛 Of course, two obstacles remain: 1) I haven't checked if I just checked package sets and they do already have both purescript-parsing
/purescript-string-parsers
is in package sets yet (which I'll submit a PR to add now if it's not) and 2) Test.Codewars.BlackList
still needs to be implemented ourselves (which ATM I have no clue how to do, even after inspecting the equivalent Haskell code 😛 ).purescript-parsing
and purescript-string-parsers
so adding either/both libraries to Codewars should be trivial (if only for implementing Test.Codewars.BlackList
in the (near?) future).
@DonaldKellett do you know any package that works with PureScript AST? Something similar to haskell-src-exts.
@Bubbler-4 cleaned up Test.Codewars.BlackList
and we now have Test.Hspec.Codewars.
I did a quick search on Pursuit and none of "purescript-src-exts", "Language.PureScript.Exts", "PureScript.Exts", "Exts", "AST", etc. returned relevant results. The closest(?) I got with "AST" was some AST
datatype for something called Kubernetes but is probably totally irrelevant to working with PureScript's AST.
I think I found something relevant: parseModule
is a Parsec parser that yields a Module
, and that Module
has a list of Declarations
, one constructor of which is ImportDeclaration
.
The problem is that everything is written in Haskell so I have no idea what to do with that.
Probably you're better off studying the relevant parser and building an equivalent parser in Purescript. That's somewhat complicated, though I believe the whole import declaration can be summarized into a regex. Probably I can try that if I get lots of spare time.
There's also Vim syntax highlighter for Purescript, in case someone knows how to read it.
From codewars/codewars-runner-cli#691 :