Skip to content

Commit 68bebc5

Browse files
authored
Add OCaml (#846)
1 parent 1aa2f58 commit 68bebc5

File tree

8 files changed

+82
-1
lines changed

8 files changed

+82
-1
lines changed

config/langs.toml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,26 @@ for arg in commandLineParams():
639639
echo arg
640640
'''
641641

642+
[OCaml]
643+
size = '207 MiB'
644+
version = '4.14.0'
645+
website = 'https://ocaml.org'
646+
example = '''
647+
(* Printing *)
648+
print_endline "Hello, World!";
649+
650+
(* Looping *)
651+
for i = 0 to 9 do
652+
Printf.printf "%d\n" i
653+
done;
654+
655+
(* Accessing arguments *)
656+
Sys.argv
657+
|> Array.to_list
658+
|> List.tl
659+
|> List.iter print_endline;
660+
'''
661+
642662
[Pascal]
643663
size = '30.9 MiB'
644664
version = '3.2.2'

db/a-schema.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ CREATE TYPE lang AS ENUM (
5454
'assembly', 'awk', 'bash', 'basic', 'brainfuck', 'c', 'c-sharp', 'cpp',
5555
'cobol', 'crystal', 'd', 'dart', 'elixir', 'f-sharp', 'fish', 'fortran',
5656
'go', 'golfscript', 'haskell', 'hexagony', 'j', 'java', 'javascript',
57-
'julia', 'k', 'lisp', 'lua', 'nim', 'pascal', 'perl', 'php', 'powershell',
57+
'julia', 'k', 'lisp', 'lua', 'nim', 'ocaml', 'pascal', 'perl', 'php', 'powershell',
5858
'prolog', 'python', 'r', 'raku', 'ruby', 'rust', 'sed', 'sql', 'swift',
5959
'tcl', 'v', 'viml', 'wren', 'zig'
6060
);

docker/dev.Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ COPY --from=codegolf/lang-d ["/", "/langs/d/rootfs/" ] # 293 M
1414
COPY --from=codegolf/lang-julia ["/", "/langs/julia/rootfs/" ] # 282 MiB
1515
COPY --from=codegolf/lang-basic ["/", "/langs/basic/rootfs/" ] # 268 MiB
1616
COPY --from=codegolf/lang-zig ["/", "/langs/zig/rootfs/" ] # 262 MiB
17+
COPY --from=codegolf/lang-ocaml ["/", "/langs/ocaml/rootfs/" ] # 207 MiB
1718
COPY --from=codegolf/lang-crystal ["/", "/langs/crystal/rootfs/" ] # 203 MiB
1819
COPY --from=codegolf/lang-powershell ["/", "/langs/powershell/rootfs/"] # 174 MiB
1920
COPY --from=codegolf/lang-elixir ["/", "/langs/elixir/rootfs/" ] # 168 MiB

docker/live.Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ COPY --from=codegolf/lang-d ["/", "/langs/d/rootfs/" ] # 293 M
2727
COPY --from=codegolf/lang-julia ["/", "/langs/julia/rootfs/" ] # 282 MiB
2828
COPY --from=codegolf/lang-basic ["/", "/langs/basic/rootfs/" ] # 268 MiB
2929
COPY --from=codegolf/lang-zig ["/", "/langs/zig/rootfs/" ] # 262 MiB
30+
COPY --from=codegolf/lang-ocaml ["/", "/langs/ocaml/rootfs/" ] # 207 MiB
3031
COPY --from=codegolf/lang-crystal ["/", "/langs/crystal/rootfs/" ] # 203 MiB
3132
COPY --from=codegolf/lang-powershell ["/", "/langs/powershell/rootfs/"] # 174 MiB
3233
COPY --from=codegolf/lang-elixir ["/", "/langs/elixir/rootfs/" ] # 168 MiB

hole/play.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,8 @@ func play(ctx context.Context, holeID, langID, code string, score *Scorecard) {
241241
cmd.Env = []string{"HOME=/"}
242242
case "nim":
243243
cmd.Args = []string{"/usr/bin/nim", "--colors:on", "-o:/tmp/code", "-r", "c", "-"}
244+
case "ocaml":
245+
cmd.Args = []string{"/usr/bin/ocaml", "/proc/self/fd/0"}
244246
case "perl":
245247
cmd.Args = []string{"/usr/bin/perl", "-E", code, "--"}
246248
case "powershell":

js/_codemirror.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import { julia } from '@codemirror/legacy-modes/mode/julia';
3838
import { k } from 'codemirror-lang-k';
3939
import { lua } from '@codemirror/legacy-modes/mode/lua';
4040
import { nim } from 'nim-codemirror-mode';
41+
import { oCaml } from '@codemirror/legacy-modes/mode/mllike';
4142
import { pascal } from '@codemirror/legacy-modes/mode/pascal';
4243
import { perl } from '@codemirror/legacy-modes/mode/perl';
4344
import { php } from '@codemirror/lang-php';
@@ -131,6 +132,7 @@ export const extensions = {
131132
'lisp': StreamLanguage.define(commonLisp),
132133
'lua': StreamLanguage.define(lua),
133134
'nim': StreamLanguage.define({ ...nim( {}, {} ), languageData: { commentTokens: { line: '#' } } }),
135+
'ocaml': StreamLanguage.define(oCaml),
134136
'pascal': StreamLanguage.define(pascal),
135137
'perl': StreamLanguage.define(perl),
136138
'php': php({ plain: true }),

langs/ocaml/Dockerfile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM alpine:3.17 as builder
2+
3+
RUN apk add --no-cache ocaml=4.14.0-r0
4+
5+
FROM codegolf/lang-base
6+
7+
COPY --from=0 /usr/bin /usr/bin
8+
COPY --from=0 /usr/lib/ocaml /usr/lib/ocaml
9+
COPY --from=0 /lib/ld-musl-x86_64.so.1 /lib/
10+
11+
ENTRYPOINT ["/usr/bin/ocaml"]
12+
13+
CMD ["--version"]

svg/ocaml.svg

Lines changed: 42 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)