Skip to content

Tags: enetx/g

Tags

v1.1.1

Toggle v1.1.1's commit message
feat!: make every rand function generic over its numeric arguments

Integer parameters accept any integer type and float parameters any float
type; the result follows the argument's type where one exists:
RangeInclusive[T] returns T for the full domain of any width, signed or
unsigned, without overflow or bias; Perm[T] returns Slice[T]; Uniform[T]
returns T; Chance[T] takes any float; Choices/Sample take k of any integer
type; Bytes/String/SecureBytes/SecureString take length of any integer type.

BREAKING CHANGES:
- calls with g-typed arguments compile unchanged (T infers to g.Int/g.Float),
  but untyped constants now infer their default types: rand.Perm(5) yields
  Slice[int] (was Slice[g.Int]) and rand.Uniform(1.5, 2.0) returns float64
  (was g.Float) — pass g.Int(5) / g.Float(1.5) to keep g-typed results

Deliberately NOT generic:
- zero-argument Float/NormFloat/Bool — with nothing to infer from, a type
  parameter would force explicit instantiation at every call site
- letters stays ...g.String — an empty variadic cannot infer a ~string
  parameter (rand.String(10) would not compile; verified against the
  compiler), and untyped string literals convert implicitly anyway

tests/rand: TestGenericArguments pins inference across uint8/int8/uint16/
int32/int64/uint/float32/g.Float call shapes.

v1.1.0

Toggle v1.1.0's commit message
feat!: de-weld the type graph — importer cost ×21 down; fs/rx/rand su…

…bpackages, collector API, eager splitters

Naming any g type no longer drags the whole container/iterator graph into the
importing package: 33,332 → 1,557 compiled functions in a package that merely
names g.String (probe compile 3.8 s / 1.5 GB → 0.05 s / 34 MB; full library
rebuild 1.15 s / 438 MB).

BREAKING CHANGES:
- 8 iterator families collapse to Seq[V] and Seq2[K, V] (+ SeqSlices as the
  instantiation-cycle guard, SeqResult unchanged); SeqSlice/SeqMap/SeqMapOrd/
  SeqSet/SeqDeque/SeqHeap are gone
- Collect() returns a lazy collector; materialize with .Slice(), .Set[T](),
  .Map[K, V](), .MapOrd[K, V](), .MapSafe[K, V](), .Pairs(), .Deque(),
  .Heap(cmp), .Slices(). Bare Collect() no longer consumes the sequence;
  explicit type arguments are required where Go cannot express the constraint
  on the method
- String/Bytes splitters are eager: Split/SplitAfter/SplitN/Lines/Fields/
  FieldsBy return []String / []Bytes, Chars returns []rune, Chunks returns a
  plain slice — range over them yields (index, value)
- File/Dir move to g/fs (Move aliases dropped; CreateTempFile is a free
  function); String/Bytes regexp methods move to g/rx; ALL random methods
  (Int.Random/RandomRange, Slice.Random/RandomSample/Shuffle, MapOrd.Shuffle,
  String.Random) move to g/rand
- Format placeholders access data only ({}, {1}, {name}, {1.Field}); method
  modifiers are removed — transform values before formatting; literal braces
  escape as {{ }} instead of \{ \}
- Set algebra is eager: Union/Intersection/Difference/SymmetricDifference
  return Set[T]; ContainsAny/ContainsAll take variadic values (set-vs-set is
  Subset/Superset/Disjoint); Set.Slice and Deque.Slice removed — use
  Iter().Collect().Slice()
- Take/Skip/StepBy take Int; negative values clamp to zero
- constructors pruned in favor of *Of: DequeFromSlice, SetFromSlice,
  HeapFromSlice, MapFromPairs, MapOrdFromPairs, MapSafeFromPairs,
  MapOrdFromStd
- renames: UInt* → Uint*, ASCII_LETTERS → ASCIILetters, DIGITS → Digits,
  HEXDIGITS → HexDigits, OCTDIGITS → OctDigits, PUNCTUATION → Punctuation
- encdec unification: Base64*/Hex/Binary encode on Bytes returns Bytes;
  zlib/gzip/flate are canonical on Bytes, String delegates zero-copy
- rand.N panics when n <= 0 (math/rand/v2 semantics)
- drop the github.com/enetx/iter dependency — the iterator core is inlined;
  the only remaining dependency is golang.org/x/text

Added:
- g/rx: compile-once Regex — IsMatch, Find, FindIter, Captures, CapturesIter,
  Index, Replace and ReplaceBy (first match), ReplaceAll, ReplaceAllBy, Split,
  SplitN, plus *Bytes variants; lazy sequences plug into iterator chains
- g/rand: N, Range, RangeInclusive, Float, Uniform, NormFloat, Bool, Chance,
  Perm, Choice, Choices, Sample, Shuffle (generic over ~[]E), Bytes, String,
  and crypto/rand-backed SecureBytes/SecureString (rejection sampling, no
  modulo bias)
- g/fs: File/Dir with lazy Lines/Chunks (SeqResult), guarded I/O, Walk/Glob
- Pair.Unpack() (K, V) — tuple-style destructuring
- Seq2.MapTo, Seq2.Unzip; map conversions (MapOrdFromMap, MapSafeFromMap,
  MapFromMapOrd, MapSafeFromMapOrd, MapFromMapSafe, MapOrdFromMapSafe);
  TransformSlice exported
- tests/budget_test.go pins the de-weld: the primitive layer must not name
  containers, splitters must return plain slices

Internal:
- the private iterator core is flattened into the public methods; only
  genuinely shared helpers remain (seqNext/seqPull/seqToSlice/seqDedupBy/
  seqFromSlice/seqFromChan, seq2Next/seq2Pull/seq2ToPairs/seqFromPairs)
- tests and examples uniformly dot-import g; subpackage tests mirror their
  packages (tests/rand joins tests/fs, tests/rx, ...)
- full comment audit against the current API; README rewritten; examples
  executed and their output comments verified
- vendored internal/ files: stale "LICENSE file" pointer lines removed
  (Go Authors copyright notices retained)

v1.0.229

Toggle v1.0.229's commit message
remove brotli, zstd

v1.0.228

Toggle v1.0.228's commit message
fix tests

v1.0.227

Toggle v1.0.227's commit message
feat!: SeqResult lazy transformers are consumer-driven on Err

Map, Filter, Exclude, Dedup, Unique, Skip, StepBy, Take, Chain, Intersperse,
Inspect, Scan, and FlatMap no longer terminate the sequence at the first Err:
the Err is yielded downstream like any other element and the source keeps
iterating for as long as the consumer keeps accepting values. Previously the
transformer itself returned false after yielding an Err, so a single transient
error silently truncated the rest of the stream even when the consumer wanted
to skip it.

Fail-fast is now exclusively the consumer's choice, matching the Rust idiom
(itertools map_ok/filter_ok + try_* terminals):
- break on the Err element (yield returns false), or
- use the short-circuiting terminals — TryCollect, Fold, Reduce, All, Any,
  First, Find, Nth — whose behavior is unchanged.

Err elements stay transparent to transformer logic: Take/Skip count only Ok
elements, Dedup/Unique exclude Err from comparison state, Intersperse emits no
separator around an Err.

Tests: new result_iter_errcont_test.go covers continuation for all 13
transformers plus guards locking consumer-break and TryCollect fail-fast; the
two tests that encoded the old terminate-on-Err contract (FlatMap cross-type,
ErrSeq Chain) now assert both sides — continuation under a continuing consumer
and fail-fast under a breaking one.

v1.0.226

Toggle v1.0.226's commit message
feat!: Go 1.27 generic methods — type-changing chains, jsonv2, checke…

…d math, API consolidation

BREAKING CHANGES:
- require Go 1.27: iterator and monad chains change payload type in-chain
  (Map[U], Then[U], ThenOf[U], FilterMap[U], FlatMap[U], Fold[A], Scan[A],
  MapOr[U]); Transform[U] is a universal pipe on every wrapper type
- drop pre-1.27 workarounds: TransformSlice/TransformSet/TransformOption/
  TransformResult(Of), MapOption, MapSeqResult, FlattenResult, package-level
  Flatten and Counter, Slice.AsAny, eager Slice.Map/Set.Map, Int.Wrapping*,
  Slice.MaxBy/MinBy, SeqHeap.Eq, Option.Result alias, Int.IsNonNegative
- Zip is fully typed: Zip[U](other) -> SeqPairs[V, U]; SeqPairs.Collect returns
  []Pair by design (generic-method instantiation cycle)
- Split(sep) requires an explicit separator (String and Bytes); Chars() is the
  canonical per-rune iteration
- Int.IsPositive is strict (> 0); String.TryBigInt returns Result;
  GroupBy renamed to ChunkBy (Rust slice::chunk_by semantics);
  File/Dir Exist -> Exists; Dir.Temp/Dir.CreateTemp -> package TempDir/
  CreateTempDir; pool.Reset panics while tasks are running
- JSON is encoding/json/v2: Option/Result implement MarshalJSONTo/
  UnmarshalJSONFrom; invalid UTF-8 and duplicate object keys are rejected;
  nil slices marshal as []; Slice.Set returns Option instead of panicking

Added:
- Int checked/saturating/overflowing arithmetic, Clamp, Signum, Neg;
  Float math and classification (IsNaN/IsInf/IsFinite/IsNormal, Signum,
  Ceil/Floor/Trunc/Fract, Clamp, Recip, Copysign, MulAdd (FMA), Hypot, Cbrt,
  Exp/Ln families, trig, ToDegrees/ToRadians, IsSignPositive/IsSignNegative)
- Result JSON ({"ok": v} / {"err": "msg"}); Result Or/OrElse/IsOkAnd/IsErrAnd/
  InspectErr/UnwrapErr/MapOr/MapOrElse; Option MapOr/MapOrElse/IsNoneOr/ThenOf
- Bytes<->String parity: JSON/URL/HTML/Rot13/Octal codecs; byte-wise Cut,
  Similarity, Truncate, LeftJustify/RightJustify/Center, IsASCII, IsDigit,
  Chunks, SubBytes, ReplaceMulti, Remove, ReplaceNth; Runes -> Slice[rune]
- adapters: TakeWhile/SkipWhile across all seq types; CounterBy[K];
  FilterByKey/FilterByValue (SeqMap/SeqMapOrd/SeqPairs); SeqResult TryCollect/
  Fold/Reduce/Scan/FlatMap/Map[U]; SeqSet First/Last/StepBy/MaxBy/MinBy/Chan/
  CounterBy/Difference/Intersection/Partition; SeqMap(Ord) All/Any/Last/Chan/
  Fold/FilterMap; full SeqPairs surface
- constructors MapOf/MapOrdOf/HeapOf/PairOf; f.Id; Set.Disjoint; Heap.Eq/Ne
- package documentation (doc.go), CHANGELOG.md, fuzz targets,
  CI pinned to Go 1.27.0-rc.1

Fixed:
- SubSlice crash with negative step at start == len (Python slicing semantics)
- SeqMapOrd.Collect and MapOrdOf were O(n^2), now O(n); OrdEntry caches its
  index instead of rescanning per operation
- format engine no longer invokes zero-return methods via reflection
- SQL driver conversion guards uint > MaxInt64; Result.Expect reports caller;
  deque/pool/heap panic messages normalized with package prefixes
- examples restructured to one program per directory (go build ./... clean)

v1.0.225

Toggle v1.0.225's commit message
remove MapResult

v1.0.224

Toggle v1.0.224's commit message
fix FlattenResult

v1.0.223

Toggle v1.0.223's commit message
feat(iter): add Flatten/FlattenResult, fix Float.String to use decima…

…l format

v1.0.222

Toggle v1.0.222's commit message
ErrSeq, OkSeq