Define polymorphic lenses and compile the runtime library

This commit is contained in:
milner committed 2019-02-11 13:34:00 +00:00
commit d30dc5d519
9 files changed
+61

No files matched your search

+5
View File
@@ -0,0 +1,5 @@
*.cmi
*.cmo
*.cma
*.byte
rewrite
+3
View File
@@ -0,0 +1,3 @@
version = "0.1.0"
description = "Record accessors and composable lenses"
archive(byte) = "fieldglass.cma"
+20
View File
@@ -0,0 +1,20 @@
OCAMLC ?= ocamlc
.PHONY: all test clean
all: fieldglass.cma
fieldglass.cmi: fieldglass.mli
$(OCAMLC) -c $<
fieldglass.cmo: fieldglass.ml fieldglass.cmi
$(OCAMLC) -c $<
fieldglass.cma: fieldglass.cmo
$(OCAMLC) -a $< -o $@
test: all
$(OCAMLC) fieldglass.cma runtime.ml -o runtime.byte
./runtime.byte
clean:
rm -f *.cmi *.cmo *.cma *.byte rewrite
+5
View File
@@ -0,0 +1,5 @@
# fieldglass
Lenses for reading and updating immutable data in OCaml.
Build with `make`; run the checks with `make test`.
+1
View File
@@ -0,0 +1 @@
lib: ["fieldglass.cmi" "fieldglass.cma" "fieldglass.mli" "META"]
+5
View File
@@ -0,0 +1,5 @@
type ('s, 't, 'a, 'b) lens = ('s -> 'a) * ('b -> 's -> 't)
type ('s, 'a) lens' = ('s, 's, 'a, 'a) lens
let lens ~view ~set = view, set
let view (get, _) = get
+5
View File
@@ -0,0 +1,5 @@
type ('s, 't, 'a, 'b) lens = ('s -> 'a) * ('b -> 's -> 't)
type ('s, 'a) lens' = ('s, 's, 'a, 'a) lens
val lens : view:('s -> 'a) -> set:('b -> 's -> 't) -> ('s, 't, 'a, 'b) lens
val view : ('s, 't, 'a, 'b) lens -> 's -> 'a
+11
View File
@@ -0,0 +1,11 @@
opam-version: "1.2"
name: "fieldglass"
version: "0.1.0"
maintainer: "rack"
authors: ["rack"]
homepage: "https://github.com/rackquiem/fieldglass"
bug-reports: "https://github.com/rackquiem/fieldglass/issues"
dev-repo: "git+https://github.com/rackquiem/fieldglass.git"
build: [make]
build-test: [make "test"]
available: [ocaml-version = "4.06.1"]
+6
View File
@@ -0,0 +1,6 @@
open Fieldglass
let sample : (string * bool, string) lens' =
lens ~view:fst ~set:(fun value (_, other) -> value, other)
let () = assert (view sample ("colour", true) = "colour")