diff --git a/README.md b/README.md index 1b4a89f..4780444 100644 --- a/README.md +++ b/README.md @@ -1,19 +1,24 @@ # ezhttp HTTP client and server for [Bend 2](https://github.com/bendlang/bend). -It needs bend 2.0.32 or later (the server binds `TCP.listen(host, port)`). ## Install -With [Bend](https://github.com/bendlang/bend) alone there is nothing to -install: import ezhttp by its hub name and `bend` fetches it from +It needs bend 2.0.32 or later (the server binds `TCP.listen(host, port)`). +ezhttp is built and checked on bend 2.0.34. + +With [Bend](https://github.com/bendlang/bend) alone there is no install +step: import ezhttp by its hub name and `bend` fetches it from [the hub](https://hub.bend-lang.com) into `~/.bend/lib` on the first run. -`0x5e4e2a9db839a0214ace6923b04b685b` is ezhttp v0.6.0. +`emerging-ezhttp@0.8.0.0` is ezhttp v0.8.0: ``` -import 0x5e4e2a9db839a0214ace6923b04b685b/main.bend as Http +import emerging-ezhttp@0.8.0.0/main.bend as Http ``` +That name resolves to `0xf1c957a470368870a6d1d62a8c0cbe32`. +To pin by content instead, import `0xf1c957a470368870a6d1d62a8c0cbe32/main.bend`. + Or with [ez](https://github.com/Emerging-Patterns/ez), which records the package in `ez.toml` (`ez init` makes one): @@ -42,8 +47,8 @@ wire/runtime layer (`EZ_LIBSSL` when needed). `https` selects that TLS path and port 443. ``` -import 0x5e4e2a9db839a0214ace6923b04b685b/main.bend as Http -import 0x5e4e2a9db839a0214ace6923b04b685b/src/client.bend as Client +import emerging-ezhttp@0.8.0.0/main.bend as Http +import emerging-ezhttp@0.8.0.0/src/client.bend as Client def main() -> IO(Client.Response): Http.http.get("https://example.com/") @@ -64,8 +69,8 @@ per connection, calls a pure handler, and writes one response in v0 for the server. A HEAD response is written with an empty body. ``` -import 0x5e4e2a9db839a0214ace6923b04b685b/main.bend as Http -import 0x5e4e2a9db839a0214ace6923b04b685b/src/http.bend as Msg +import emerging-ezhttp@0.8.0.0/main.bend as Http +import emerging-ezhttp@0.8.0.0/src/http.bend as Msg def handle(req: Msg.Request) -> Msg.Reply: match req: @@ -81,10 +86,10 @@ def main() -> IO(Unit): Cookies, `Cache-Control`, and CORS are pure helpers on the same messages. ``` -import 0x5e4e2a9db839a0214ace6923b04b685b/main.bend as Http -import 0x5e4e2a9db839a0214ace6923b04b685b/src/http.bend as Msg -import 0x5e4e2a9db839a0214ace6923b04b685b/src/cookie.bend as Cookie -import 0x5e4e2a9db839a0214ace6923b04b685b/src/cors.bend as Cors +import emerging-ezhttp@0.8.0.0/main.bend as Http +import emerging-ezhttp@0.8.0.0/src/http.bend as Msg +import emerging-ezhttp@0.8.0.0/src/cookie.bend as Cookie +import emerging-ezhttp@0.8.0.0/src/cors.bend as Cors def authed() -> Msg.Header: Http.basic("user", "pass") @@ -100,8 +105,8 @@ def cross(cfg: Cors.Cfg, req: Msg.Request, reply: Msg.Reply) -> Msg.Reply: ``` ``` -import 0x81c67699424929b5c44cd8577e18117f/main.bend as Ezjson -import 0x81c67699424929b5c44cd8577e18117f/src/value.bend as Value +import emerging-ezjson@1.1.0.0/main.bend as Ezjson +import emerging-ezjson@1.1.0.0/src/value.bend as Value def read.of(got: Maybe<&2, Value.Json>) -> Maybe<&2, String>: match got: diff --git a/ez.lock.toml b/ez.lock.toml index c95f606..032c04b 100644 --- a/ez.lock.toml +++ b/ez.lock.toml @@ -23,8 +23,8 @@ LICENSE = "309f5aae946e4db157750e002fb179a74ed0fe27fce09a7be68a6977b14f205f" [tools] [tools.bolt] git = "https://github.com/Emerging-Patterns/bolt" -rev = "d5a67600a96ba423f2212bd661a30c1fba38eb55" -tag = "v1.9.0" +rev = "91efe4bbaad91953652794ad55be7b49c10a2eff" +tag = "v1.11.0" root = "." -narHash = "sha256-HmJ8J1xDshBdSWXIiEp48GZ9qHsm+bmpHw06ZWwcDVE=" +narHash = "sha256-0xjoxoByI8PKBrbFy4eYGbKQ3ZVscknZLKkWQroYAUI=" entry = "main.bend" diff --git a/ez.toml b/ez.toml index cc89629..c2ae09b 100644 --- a/ez.toml +++ b/ez.toml @@ -1,7 +1,7 @@ [package] name = "ezhttp" entry = "main.bend" - +[deps] [deps.ezjson] hash = "0x81c67699424929b5c44cd8577e18117f" git = "https://github.com/Emerging-Patterns/ezjson" @@ -10,11 +10,11 @@ tag = "v1.1.0" root = "." narHash = "sha256-yHxl1aW4luf2bdPqOUcULhOEZLlcaTOWjTrPJys4CMI=" entry = "main.bend" - +[tools] [tools.bolt] git = "https://github.com/Emerging-Patterns/bolt" -rev = "d5a67600a96ba423f2212bd661a30c1fba38eb55" -tag = "v1.9.0" +rev = "91efe4bbaad91953652794ad55be7b49c10a2eff" +tag = "v1.11.0" root = "." -narHash = "sha256-HmJ8J1xDshBdSWXIiEp48GZ9qHsm+bmpHw06ZWwcDVE=" +narHash = "sha256-0xjoxoByI8PKBrbFy4eYGbKQ3ZVscknZLKkWQroYAUI=" entry = "main.bend" diff --git a/flake.lock b/flake.lock index d916190..3b6393c 100644 --- a/flake.lock +++ b/flake.lock @@ -21,38 +21,21 @@ "type": "github" } }, - "bend_2": { - "inputs": { - "nixpkgs": "nixpkgs" - }, - "locked": { - "lastModified": 1790482124, - "narHash": "sha256-Gv309ikt48M8cISbwSo6V0md2572iieIRiyl3noF1cA=", - "owner": "bendlang", - "repo": "bend", - "rev": "af569d4826913b2ce3557e9829ccad31fcf86f94", - "type": "github" - }, - "original": { - "owner": "bendlang", - "repo": "bend", - "rev": "af569d4826913b2ce3557e9829ccad31fcf86f94", - "type": "github" - } - }, "ez": { "inputs": { - "bend": "bend_2", + "bend": [ + "bend" + ], "nixpkgs": [ "nixpkgs" ] }, "locked": { - "lastModified": 1790364897, - "narHash": "sha256-WBj/Hg/Gys7sIz/IYt204QEGQPjQ/qw0TpcXAYpuGQI=", + "lastModified": 1790728722, + "narHash": "sha256-6SDNpCeAfR66xuSO8vkoBMZAQ24ZUyGYLc9GFadFYy8=", "owner": "Emerging-Patterns", "repo": "ez", - "rev": "94d441e9b58e8b6a8a2f6cb8a74ae35d13b47ceb", + "rev": "b5693ce28337e770b2c70c99d53d311cd044dc24", "type": "github" }, "original": { @@ -62,22 +45,6 @@ } }, "nixpkgs": { - "locked": { - "lastModified": 1790185690, - "narHash": "sha256-xJ+X4hBtOcAFGBOe5nAMyMUeF9foJBmIOu3NjBqBycU=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "4975466d324710c576dc11ad614684e6bd8cad8e", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixos-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "nixpkgs_2": { "locked": { "lastModified": 1789921291, "narHash": "sha256-Ft/BRnIqw1MywFoXydKobjjWmDFgDdYtSpJliE8+yUw=", @@ -97,7 +64,7 @@ "inputs": { "bend": "bend", "ez": "ez", - "nixpkgs": "nixpkgs_2" + "nixpkgs": "nixpkgs" } } }, diff --git a/flake.nix b/flake.nix index 8075c7a..db2453c 100644 --- a/flake.nix +++ b/flake.nix @@ -8,13 +8,12 @@ url = "github:bendlang/bend/777ee0b55c485afdd7e68bd917b3d23a88d77371"; inputs.nixpkgs.follows = "nixpkgs"; }; + # ez 1.3.0 runs on bend 2.0.34, so its bend follows this flake's bend: + # ez, `ez prove` and bolt all build on 2.0.34. inputs.ez = { url = "github:Emerging-Patterns/ez"; inputs.nixpkgs.follows = "nixpkgs"; - # ez and its bolt stay on the bend ez's own flake.lock records until ez - # releases on 2.0.34, so ez's inputs.bend is pinned, not followed. The - # package's own builds and its proofs (checks.proofs) run on 2.0.34. - inputs.bend.url = "github:bendlang/bend/af569d4826913b2ce3557e9829ccad31fcf86f94"; + inputs.bend.follows = "bend"; }; outputs = { self, nixpkgs, ... }@inputs: @@ -25,7 +24,7 @@ ez = inputs.ez.lib.${system}; ezBin = inputs.ez.packages.${system}.default; bend = inputs.bend.packages.${system}.default; - bolt = ez.toolPackage { name = "bolt"; src = self; wrapFlags = [ "--gpu" "off" ]; }; + bolt = ez.toolPackage { name = "bolt"; src = self; inherit bend; wrapFlags = [ "--gpu" "off" ]; }; bend-cc = ez.bend-cc; bench = import ./bench { @@ -42,22 +41,16 @@ apps.${system} = bench.apps; checks.${system} = { - # every PROOF.bend on this flake's bend: its first line must be - # ALL PROOFS CHECK. ez.mkProofs comes back when ez runs on 2.0.34. - # ENTRY.bend states the laws on main.bend and client.bend, - # which reach the wire effect, so its verdict is SOME PROOFS FAIL; - # its only error may be the list of defs relying on foreign code. - proofs = pkgs.runCommand "ezhttp-proofs" { + proofs = ez.mkProofs { ez = ezBin; src = self; }; + # ENTRY.bend states the laws on main.bend and client.bend, which + # reach the wire effect, so its verdict is SOME PROOFS FAIL; its only + # error may be the list of defs relying on foreign code. + entry = pkgs.runCommand "ezhttp-entry" { nativeBuildInputs = [ bend ]; BEND_LIB = ez.bendLib ./ez.lock.toml; } '' export HOME=$TMPDIR cp -r ${self} src && chmod -R u+w src && cd src - for p in $(find . -name PROOF.bend -not -path './.ez/*' | sort); do - first=$(cd "$(dirname "$p")" && bend "$(basename "$p")" | head -n 1) - echo "$p: $first" - [ "$first" = "ALL PROOFS CHECK" ] || exit 1 - done out_entry=$(bend ENTRY.bend 2>&1 || true) echo "$out_entry" | head -n 2 [ "$(echo "$out_entry" | sed -n 1p)" = "SOME PROOFS FAIL" ] || exit 1