-
-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Script to redeploy testlib.sml to all exercises on changes. #206
Changes from 5 commits
156c591
627c2dc
110d8d7
721dd7b
32774e5
f276a74
d4c26df
48de3e8
f75f658
57b3885
38dff0e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
structure Path = OS.Path | ||
structure File = OS.FileSys | ||
|
||
fun printLn x = print (x ^ "\n") | ||
|
||
fun fileExists x = File.access (x,[]) | ||
|
||
fun testLibName base slug = | ||
Path.joinDirFile | ||
{ | ||
dir = (Path.concat (base,slug)), | ||
file = "testlib.sml" | ||
} | ||
|
||
fun dirList dirname = | ||
let | ||
fun go d xs = | ||
case File.readDir d of | ||
SOME x => go d (x::xs) | ||
| NONE => (File.closeDir d; xs) | ||
in | ||
go (File.openDir dirname) [] | ||
end | ||
|
||
fun fileBytes path = | ||
let | ||
val in' = BinIO.openIn path | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it some well-established convention to call this Actually I have checked that my emacs with SML mode does not have this issue, but even there I would prefer not to call it There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I considered changing it in case it is confusing, but using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree that bad tooling is not the best reason for a change, but this was just for information. I have nothing against My question about conventions was more specifically about using the exact string So if you already considered it to be confusing why not change it to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, you are right. Prime here is not really really semantically consistent, but rather it is a syntactic hack to get around not having my There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The longer name of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, @kotp. Yes, you are right about |
||
val bytes = BinIO.inputAll in' | ||
in | ||
BinIO.closeIn in'; bytes | ||
end | ||
|
||
fun writeFileBytes bytes path = | ||
let | ||
val out = BinIO.openOut path | ||
in | ||
BinIO.output (out, bytes); | ||
BinIO.closeOut out | ||
end | ||
|
||
fun relUnixPathToAbs x= Path.concat ((File.getDir ()), Path.fromUnixPath x) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing space in |
||
|
||
val _ = | ||
let | ||
val concept = relUnixPathToAbs "exercise/concept" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
val practice = relUnixPathToAbs"exercises/practice" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing space in |
||
val testLib = fileBytes "lib/testlib.sml" | ||
in | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would you mind writing |
||
app (writeFileBytes testLib o testLibName practice) (dirList practice) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think a very short docstring explaining what the script does might be a good idea (maybe at the top of the file). Of course the filename essentially says it but I would still prefer a short docstring. Let me know if you think this would not be helpful. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A comment basically restating the name of the script seems pretty redundant to me. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK I am fine with that, I was just a little bit worried if somebody else might wonder what exactly "redeploy" might mean. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, well, I often take for granted that English is my first language, aber meine Meinung nach sollen wir die Problemen sprachlicher Mehrdeutigkeit der Nicht-Muttersprachlichern beachten 🙃 So, maybe it is best for there to be some more direct comments in the script 😄 |
||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing space in
dir = (Path.concat (base,slug)),
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What space? I don't have a space between
x
and[]
in line 6,File.access (x,[])
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe for consistency with testlib one could write
f(x, y)
instead off(x,y)
everywhere. But think it is not important. Consistency can also be a pain :D.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Space after comma,after all,is helpful in reading,so they say. I do not know why,in any instance,one would not use a space,every time,after a comma.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I got used to it, because a lot of old SML doesn't use spaces in tuples. Of course, a lot of old SML tries to immitate c-style function calls by excluding a space between uncurried function names and their product argument; this convention really annoys me, so I don't need to stick with the other convention for a partial tradition either. I will change it if you all think it is better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is the difference of my eyes seeing the comma, and not seeing it. So white space in code, when not syntactically limited to white space breaking things when there can definitely benefit from having it.