1{ stdenv, lib, fetchurl, ocaml, findlib, ocamlbuild, topkg }:
2
3let
4 # Use astring 0.8.3 for OCaml < 4.05
5 param =
6 if lib.versionAtLeast ocaml.version "4.05"
7 then {
8 version = "0.8.5";
9 sha256 = "1ykhg9gd3iy7zsgyiy2p9b1wkpqg9irw5pvcqs3sphq71iir4ml6";
10 } else {
11 version = "0.8.3";
12 sha256 = "0ixjwc3plrljvj24za3l9gy0w30lsbggp8yh02lwrzw61ls4cri0";
13 };
14in
15
16stdenv.mkDerivation {
17 pname = "ocaml${ocaml.version}-astring";
18 inherit (param) version;
19
20 src = fetchurl {
21 url = "https://erratique.ch/software/astring/releases/astring-${param.version}.tbz";
22 inherit (param) sha256;
23 };
24
25 nativeBuildInputs = [ ocaml findlib ocamlbuild topkg ];
26 buildInputs = [ topkg ];
27
28 strictDeps = true;
29
30 inherit (topkg) buildPhase installPhase;
31
32 meta = {
33 homepage = "https://erratique.ch/software/astring";
34 description = "Alternative String module for OCaml";
35 longDescription = ''
36 Astring exposes an alternative String module for OCaml. This module tries
37 to balance minimality and expressiveness for basic, index-free, string
38 processing and provides types and functions for substrings, string sets
39 and string maps.
40
41 Remaining compatible with the OCaml String module is a non-goal.
42 The String module exposed by Astring has exception safe functions, removes
43 deprecated and rarely used functions, alters some signatures and names,
44 adds a few missing functions and fully exploits OCaml's newfound string
45 immutability.
46 '';
47 license = lib.licenses.isc;
48 maintainers = with lib.maintainers; [ sternenseemann ];
49 };
50}