-
Notifications
You must be signed in to change notification settings - Fork 1
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
0 parents
commit 0f8635e
Showing
14 changed files
with
621 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
_build/ | ||
*.native | ||
*.byte | ||
ppx_defer.install |
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 @@ | ||
PKG ppx_tools.metaquot | ||
S src/ | ||
B _build/src/ |
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,21 @@ | ||
Copyright (c) 2016 Hezekiah M. Carty | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
this software and associated documentation files (the "Software"), to deal in | ||
the Software without restriction, including without limitation the rights to | ||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies | ||
of the Software, and to permit persons to whom the Software is furnished to do | ||
so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
|
||
|
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 @@ | ||
all: | ||
ocaml pkg/build.ml native=true native-dynlink=true | ||
|
||
clean: | ||
ocamlbuild -clean |
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 @@ | ||
# ppx_defer | ||
|
||
This is an OCaml language extension implementing a somewhat Go-like | ||
`[%defer expr1]; expr2` which will defer the evaluation of `expr1` until after | ||
`expr2`. | ||
|
||
Thanks to Drup for guidance in figuring out ppx details! | ||
|
||
## Using ppx_defer | ||
|
||
```ocaml | ||
let () = | ||
let ic = open_in_bin "some_file" in | ||
[%defer close_in ic]; | ||
let length = in_channel_length ic in | ||
let bytes = really_input_string ic length in | ||
print_endline bytes | ||
``` |
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 @@ | ||
true: bin_annot, safe_string | ||
|
||
<src/*.{ml,mli,byte,native}>: package(ppx_tools.metaquot) | ||
<examples/*.{ml,byte,native}>: debug |
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,6 @@ | ||
let () = | ||
let ic = open_in_bin "test.ml" in | ||
[%defer close_in ic]; | ||
let length = in_channel_length ic in | ||
let bytes = really_input_string ic length in | ||
print_endline bytes |
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 () = Ocamlbuild_plugin.Options.use_ocamlfind := true |
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 @@ | ||
opam-version: "1.2" | ||
name: "ppx_defer" | ||
version: "dev" | ||
maintainer: "Hezekiah M. Carty <[email protected]>" | ||
authors: [ "Hezekiah M. Carty <[email protected]>" ] | ||
license: "MIT" | ||
homepage: "https://github.com/hcarty/ppx_defer" | ||
bug-reports: "https://github.com/hcarty/ppx_defer/issues" | ||
dev-repo: "https://github.com/hcarty/ppx_defer.git" | ||
build:[ | ||
"ocaml" "pkg/build.ml" "native=%{ocaml-native}%" | ||
"native-dynlink=%{ocaml-native-dynlink}%" | ||
] | ||
depends: [ | ||
"ocamlfind" {build} | ||
"ocamlbuild" {build} | ||
] | ||
available: [ ocaml-version >= "4.02.3" ] |
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 @@ | ||
description = "Defer expressions until the end of the current scope" | ||
ppx = "./ppx_defer" |
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,11 @@ | ||
#!/usr/bin/env ocaml | ||
#directory "pkg" | ||
#use "topkg.ml" | ||
|
||
let () = | ||
Pkg.describe "ppx_defer" ~builder:(`OCamlbuild []) [ | ||
Pkg.lib "pkg/META"; | ||
Pkg.bin ~auto:true "src/ppx_defer" ~dst:"../lib/ppx_defer/ppx_defer"; | ||
Pkg.doc "README.md"; | ||
Pkg.doc "LICENSE"; | ||
] |
Oops, something went wrong.