Skip to content

Commit

Permalink
Add OCaml (#846)
Browse files Browse the repository at this point in the history
  • Loading branch information
Steffan153 committed Dec 25, 2022
1 parent 1aa2f58 commit 68bebc5
Show file tree
Hide file tree
Showing 8 changed files with 82 additions and 1 deletion.
20 changes: 20 additions & 0 deletions config/langs.toml
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,26 @@ for arg in commandLineParams():
echo arg
'''

[OCaml]
size = '207 MiB'
version = '4.14.0'
website = 'https://ocaml.org'
example = '''
(* Printing *)
print_endline "Hello, World!";
(* Looping *)
for i = 0 to 9 do
Printf.printf "%d\n" i
done;
(* Accessing arguments *)
Sys.argv
|> Array.to_list
|> List.tl
|> List.iter print_endline;
'''

[Pascal]
size = '30.9 MiB'
version = '3.2.2'
Expand Down
2 changes: 1 addition & 1 deletion db/a-schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ CREATE TYPE lang AS ENUM (
'assembly', 'awk', 'bash', 'basic', 'brainfuck', 'c', 'c-sharp', 'cpp',
'cobol', 'crystal', 'd', 'dart', 'elixir', 'f-sharp', 'fish', 'fortran',
'go', 'golfscript', 'haskell', 'hexagony', 'j', 'java', 'javascript',
'julia', 'k', 'lisp', 'lua', 'nim', 'pascal', 'perl', 'php', 'powershell',
'julia', 'k', 'lisp', 'lua', 'nim', 'ocaml', 'pascal', 'perl', 'php', 'powershell',
'prolog', 'python', 'r', 'raku', 'ruby', 'rust', 'sed', 'sql', 'swift',
'tcl', 'v', 'viml', 'wren', 'zig'
);
Expand Down
1 change: 1 addition & 0 deletions docker/dev.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ COPY --from=codegolf/lang-d ["/", "/langs/d/rootfs/" ] # 293 M
COPY --from=codegolf/lang-julia ["/", "/langs/julia/rootfs/" ] # 282 MiB
COPY --from=codegolf/lang-basic ["/", "/langs/basic/rootfs/" ] # 268 MiB
COPY --from=codegolf/lang-zig ["/", "/langs/zig/rootfs/" ] # 262 MiB
COPY --from=codegolf/lang-ocaml ["/", "/langs/ocaml/rootfs/" ] # 207 MiB
COPY --from=codegolf/lang-crystal ["/", "/langs/crystal/rootfs/" ] # 203 MiB
COPY --from=codegolf/lang-powershell ["/", "/langs/powershell/rootfs/"] # 174 MiB
COPY --from=codegolf/lang-elixir ["/", "/langs/elixir/rootfs/" ] # 168 MiB
Expand Down
1 change: 1 addition & 0 deletions docker/live.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ COPY --from=codegolf/lang-d ["/", "/langs/d/rootfs/" ] # 293 M
COPY --from=codegolf/lang-julia ["/", "/langs/julia/rootfs/" ] # 282 MiB
COPY --from=codegolf/lang-basic ["/", "/langs/basic/rootfs/" ] # 268 MiB
COPY --from=codegolf/lang-zig ["/", "/langs/zig/rootfs/" ] # 262 MiB
COPY --from=codegolf/lang-ocaml ["/", "/langs/ocaml/rootfs/" ] # 207 MiB
COPY --from=codegolf/lang-crystal ["/", "/langs/crystal/rootfs/" ] # 203 MiB
COPY --from=codegolf/lang-powershell ["/", "/langs/powershell/rootfs/"] # 174 MiB
COPY --from=codegolf/lang-elixir ["/", "/langs/elixir/rootfs/" ] # 168 MiB
Expand Down
2 changes: 2 additions & 0 deletions hole/play.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,8 @@ func play(ctx context.Context, holeID, langID, code string, score *Scorecard) {
cmd.Env = []string{"HOME=/"}
case "nim":
cmd.Args = []string{"/usr/bin/nim", "--colors:on", "-o:/tmp/code", "-r", "c", "-"}
case "ocaml":
cmd.Args = []string{"/usr/bin/ocaml", "/proc/self/fd/0"}
case "perl":
cmd.Args = []string{"/usr/bin/perl", "-E", code, "--"}
case "powershell":
Expand Down
2 changes: 2 additions & 0 deletions js/_codemirror.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import { julia } from '@codemirror/legacy-modes/mode/julia';
import { k } from 'codemirror-lang-k';
import { lua } from '@codemirror/legacy-modes/mode/lua';
import { nim } from 'nim-codemirror-mode';
import { oCaml } from '@codemirror/legacy-modes/mode/mllike';
import { pascal } from '@codemirror/legacy-modes/mode/pascal';
import { perl } from '@codemirror/legacy-modes/mode/perl';
import { php } from '@codemirror/lang-php';
Expand Down Expand Up @@ -131,6 +132,7 @@ export const extensions = {
'lisp': StreamLanguage.define(commonLisp),
'lua': StreamLanguage.define(lua),
'nim': StreamLanguage.define({ ...nim( {}, {} ), languageData: { commentTokens: { line: '#' } } }),
'ocaml': StreamLanguage.define(oCaml),
'pascal': StreamLanguage.define(pascal),
'perl': StreamLanguage.define(perl),
'php': php({ plain: true }),
Expand Down
13 changes: 13 additions & 0 deletions langs/ocaml/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM alpine:3.17 as builder

RUN apk add --no-cache ocaml=4.14.0-r0

FROM codegolf/lang-base

COPY --from=0 /usr/bin /usr/bin
COPY --from=0 /usr/lib/ocaml /usr/lib/ocaml
COPY --from=0 /lib/ld-musl-x86_64.so.1 /lib/

ENTRYPOINT ["/usr/bin/ocaml"]

CMD ["--version"]
42 changes: 42 additions & 0 deletions svg/ocaml.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 68bebc5

Please sign in to comment.