-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c46c867
commit 52091c0
Showing
13 changed files
with
142 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
_build | ||
result |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
(lang dune 3.0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
{ | ||
nixConfig = { | ||
extra-substituters = "https://ocaml.nix-cache.com"; | ||
extra-trusted-public-keys = "ocaml.nix-cache.com-1:/xI2h2+56rwFfKyyFVbkJSeGqSIYMC/Je+7XXqGKDIY="; | ||
}; | ||
|
||
inputs = { | ||
nixpkgs.url = "github:nix-ocaml/nix-overlays"; | ||
flake-utils.url = "github:numtide/flake-utils"; | ||
flake-utils.follows = "nixpkgs/flake-utils"; | ||
nix-filter.url = "github:numtide/nix-filter"; | ||
}; | ||
|
||
outputs = { self, nixpkgs, flake-utils, nix-filter }: | ||
flake-utils.lib.eachDefaultSystem (system: | ||
let pkgs = nixpkgs.legacyPackages.${system}; in | ||
{ | ||
packages = { | ||
inherit (pkgs.ocamlPackages.callPackage ./nix { | ||
inherit nix-filter; | ||
doCheck = true; | ||
}) package; | ||
}; | ||
|
||
devShells = { | ||
default = pkgs.mkShell { | ||
inputsFrom = with self.packages.${system}; [ | ||
package | ||
]; | ||
|
||
nativeBuildInputs = with pkgs.ocamlPackages; [ | ||
ocaml | ||
dune | ||
|
||
ocaml-lsp | ||
|
||
ocamlformat | ||
dune-release | ||
odoc | ||
]; | ||
}; | ||
}; | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
{ pkgs | ||
, stdenv | ||
, lib | ||
, nix-filter | ||
, ocamlPackages | ||
, static ? false | ||
, doCheck | ||
}: | ||
with ocamlPackages; { | ||
package = buildDunePackage { | ||
pname = "package"; | ||
version = "1.0.0"; | ||
|
||
src = with nix-filter.lib; | ||
filter { | ||
# Root of the project relative to this file | ||
root = ./..; | ||
# If no include is passed, it will include all the paths. | ||
include = [ | ||
# Include the "src" path relative to the root. | ||
"src" | ||
"test" | ||
# Include this specific path. The path must be under the root. | ||
../package.opam | ||
../dune-project | ||
]; | ||
}; | ||
|
||
checkInputs = [ | ||
# Put test dependencies here | ||
alcotest | ||
]; | ||
|
||
propagatedBuildInputs = [ | ||
# Put dependencies here if you're creating a library | ||
]; | ||
|
||
buildInputs = [ | ||
# Put build-time dependencies here | ||
]; | ||
|
||
inherit doCheck; | ||
|
||
meta = { | ||
description = "Describe your project here"; | ||
# license = stdenv.lib.licenses.bsd3; | ||
}; | ||
}; | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
(executable | ||
(name main) | ||
(public_name package) | ||
(libraries package)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
let main () = | ||
print_string "First number: "; | ||
let first = read_line () |> int_of_string_opt in | ||
print_string "Second number: "; | ||
let second = read_line () |> int_of_string_opt in | ||
let output = | ||
match (first, second) with | ||
| None, Some _ -> "First input is not a number" | ||
| Some _, None -> "Second input is not a number" | ||
| None, None -> "Neither of the inputs is a number" | ||
| Some f, Some s -> | ||
let number = Package.add f s in | ||
Printf.sprintf "%i + %i = %i" f s number | ||
in | ||
print_endline output | ||
;; | ||
|
||
main () |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
(library | ||
(name package) | ||
(public_name package)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
let add a b = a + b |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
(test | ||
(name test) | ||
(libraries alcotest package)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
let test_add () = Alcotest.(check int) "adds numbers" 5 (Package.add 2 3) | ||
|
||
let () = | ||
let open Alcotest in | ||
run "Package" [ ("numbers", [ test_case "add" `Quick test_add ]) ] |