Haskell Examples
Haskell base64 encoder and validated decoder
Encodes strings to base64 and decodes them back, rejecting malformed lengths and characters outside the alphabet.
Haskell aligned plain-text table renderer
Renders rows as a plain-text table with per-column alignment, padding every cell to the widest value in its column.
Haskell field-level signup validation errors
Validates signup fields and returns a list of per-field messages, so callers can show each error next to its input.
Haskell URL query string encoder and parser
Percent-encodes key-value pairs into a query string and parses query strings back, decoding percent escapes safely.
Haskell JSON decode with field-level errors
Decodes JSON bytes and turns missing or mistyped fields into readable messages instead of opaque parser failures.
Haskell bounded worker pool using QSem
Runs IO actions on a fixed set of threads gated by a semaphore, returning all results in input order even when some fail.
Haskell timeout HTTP GET and JSON decode
Fetches a URL over HTTP with a microsecond timeout and decodes the JSON body, reporting timeouts and errors as Left.
Haskell environment config loader with validation
Reads typed settings from environment variables, applying defaults and reporting every validation failure at once.
Haskell token bucket rate limiter
Implements a token bucket that tolerates bursts up to a capacity while enforcing a steady average refill rate.
Haskell bounded LRU cache over Data.Map
Builds a size-bounded cache that evicts the least recently used entry, using an IORef and a map of keys to timestamps.
Haskell multi-key record sort with nulls last
Sorts records stably by several keys at once, comparing present ages before missing ones so blanks always land last.
Haskell streaming line reader with foldLinesM
Streams a file line by line with constant memory, applying a monadic fold so large inputs never load into RAM.
Haskell split a list into fixed-size batches
Splits a list into consecutive batches of at most n elements, plus a helper that pairs every batch with its index.
Haskell deep clone and recursive merge of values
Recursively copies a nested value tree and merges two objects, letting right-hand keys win and concatenating arrays.
Haskell capped exponential retry with jitter
Runs a fallible IO action with capped exponential backoff and jitter, returning the first success or the last exception.