Skip to content
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

Configure Travis #38

Merged
merged 3 commits into from
Apr 24, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 14 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
language: c
sudo: required
install: wget https://raw.githubusercontent.com/ocaml/ocaml-ci-scripts/master/.travis-opam.sh
script: bash -ex .travis-opam.sh
env:
matrix:
- OCAML_VERSION=4.03
- OCAML_VERSION=4.03 DEPOPTS=lwt
- OCAML_VERSION=4.03 DEPOPTS=async_kernel
- OCAML_VERSION=4.04
- OCAML_VERSION=4.04 DEPOPTS=lwt
- OCAML_VERSION=4.04 DEPOPTS=async_kernel
os:
- linux
16 changes: 15 additions & 1 deletion opam
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,28 @@ build: [
"--with-lwt" "%{lwt:installed}%"
"--with-async" "%{async_kernel:installed}%"
]
build-test: [
[ "ocaml" "pkg/pkg.ml" "build" "--dev-pkg" "%{pinned}%" "--tests" "true" ]
[ "ocaml" "pkg/pkg.ml" "test" ]
]
depends: [
"ocamlfind" {build}
"ocamlbuild" {build}
"topkg" {build}
"angstrom" {>= "0.3.0"}
"ppx_deriving"
"sexplib"
"ppx_sexp_conv"
"ppx_sexp_value"
"yojson"
"rresult"
"alcotest" {test}
"lwt" {test}
"async_unix" {test}
]
depopts: [
"lwt"
"async_kernel"
]
available: [
ocaml-version >= "4.03.0"
]
4 changes: 2 additions & 2 deletions src/graphql.ml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Schema = Graphql_schema.Make(struct
type +'a t = 'a

let bind x ~f = f x
let bind x f = f x
let return x = x
end)
end)
7 changes: 1 addition & 6 deletions src/graphql_lwt.ml
Original file line number Diff line number Diff line change
@@ -1,6 +1 @@
module Schema = Graphql_schema.Make(struct
type +'a t = 'a Lwt.t

let return = Lwt.return
let bind x ~f = Lwt.bind x f
end)
module Schema = Graphql_schema.Make(Lwt)
10 changes: 5 additions & 5 deletions src/graphql_schema.ml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ module type IO = sig
type +'a t

val return : 'a -> 'a t
val bind : 'a t -> f:('a -> 'b t) -> 'b t
val bind : 'a t -> ('a -> 'b t) -> 'b t
end

(* Schema *)
Expand All @@ -40,7 +40,7 @@ module Make(Io : IO) = struct
module Io = struct
include Io

let map x ~f = bind x ~f:(fun x' -> return (f x'))
let map x ~f = bind x (fun x' -> return (f x'))
let ok x = Io.return (Ok x)
let error x = Io.return (Error x)

Expand All @@ -53,14 +53,14 @@ module Make(Io : IO) = struct

module Result = struct
let return x = return (Ok x)
let bind x f = bind x ~f:(function Ok x' -> f x' | Error _ as err -> Io.return err)
let bind x f = bind x (function Ok x' -> f x' | Error _ as err -> Io.return err)
let map x ~f = map x ~f:(function Ok x' -> Ok (f x') | Error _ as err -> err)
end

let rec map_s ?(memo=[]) f = function
| [] -> Io.return (List.rev memo)
| x::xs ->
bind (f x) ~f:(fun x' -> map_s ~memo:(x'::memo) f xs)
bind (f x) (fun x' -> map_s ~memo:(x'::memo) f xs)

let rec map_p f xs =
List.map f xs |> all
Expand Down Expand Up @@ -932,4 +932,4 @@ end
execute' schema ctx doc >>| function
| Ok data -> Ok (`Assoc ["data", data])
| Error err -> Error (`Assoc ["errors", `List [`Assoc ["message", `String err]]])
end
end
4 changes: 2 additions & 2 deletions src/graphql_schema.mli
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ module type IO = sig
type +'a t

val return : 'a -> 'a t
val bind : 'a t -> f:('a -> 'b t) -> 'b t
val bind : 'a t -> ('a -> 'b t) -> 'b t
end

(* Schema *)
module Make(Io : IO) : Graphql_intf.Schema with type 'a io = 'a Io.t
module Make(Io : IO) : Graphql_intf.Schema with type 'a io = 'a Io.t
6 changes: 3 additions & 3 deletions test/async_test.ml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
open Graphql
open Async_kernel
open Async_unix
open Async_kernel.Std
open Async_unix.Std

let test_query schema ctx query expected =
Thread_safe.block_on_async_exn begin fun () ->
Expand Down Expand Up @@ -32,4 +32,4 @@ let suite = [
("execution", `Quick, fun () ->
test_query schema () "{ direct_string io_int }" "{\"data\":{\"direct_string\":\"foo\",\"io_int\":42}}"
);
]
]