Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
hcarty committed Feb 10, 2016
0 parents commit 0f8635e
Show file tree
Hide file tree
Showing 14 changed files with 621 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
_build/
*.native
*.byte
ppx_defer.install
3 changes: 3 additions & 0 deletions .merlin
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
PKG ppx_tools.metaquot
S src/
B _build/src/
21 changes: 21 additions & 0 deletions LICENSE
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.


5 changes: 5 additions & 0 deletions Makefile
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
18 changes: 18 additions & 0 deletions README.md
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
```
4 changes: 4 additions & 0 deletions _tags
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
6 changes: 6 additions & 0 deletions examples/ic.ml
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
1 change: 1 addition & 0 deletions myocamlbuild.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
let () = Ocamlbuild_plugin.Options.use_ocamlfind := true
18 changes: 18 additions & 0 deletions opam
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" ]
2 changes: 2 additions & 0 deletions pkg/META
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"
11 changes: 11 additions & 0 deletions pkg/build.ml
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";
]
Loading

0 comments on commit 0f8635e

Please sign in to comment.