r/hica • • Aug 07 '26

Rethinking design patterns in hica: when the patterns melt away

1 Upvotes

I recently read Nicolas Duminil's DZone piece Rethinking Java Design Patterns: From OOP to FP, where he shows how five Gang-of-Four patterns (Factory, Visitor, Builder, Decorator, Strategy) shrink when you shift a Java codebase toward a functional style.

It's a great article, but it got me thinking; what happens to those same patterns in a language that is FP-first like hica?

I wrote a companion piece for hica walking the same five patterns in the same order, using the same Product domain. Short version:

  • Factory, Visitor and Strategy: no hica names, because there's no scaffolding to name

  • Builder and Decorator: the names survive, but only as descriptions of a composition style; there is no builder object and no wrapper class

All five patterns fit in ~120 lines of hica, and every snippet in the article is verified by a hica test block.

Rethinking Design Patterns in hica


r/hica • • Jul 26 '26

hicurl - a modern HTTP CLI built in hica

1 Upvotes

I've been working on hicurl, an HTTP command-line tool built in hica.

It serves both as a practical CLI tool for API testing and as a showcase of hica's standard library, libcurl bindings, and native compilation.

Core Features and Benefits

  • Fast execution: Compiles to a native binary using Hica and binds directly to libcurl via Koka FFI for network I/O.

  • Built-in response filtering: Extracts fields directly from responses without requiring external tools like jq. Supports JSON dot-paths (.data.0.id), HTTP status codes (:status), headers (:header.Content-Type), session cookies (:cookie.session_id), and timing metrics (:time.ttfb).

  • Context-aware TTY output: Formats JSON with ANSI syntax highlighting in an interactive terminal, but automatically outputs raw unformatted text when output is piped to another command or script.

  • Directory-aware environment handling: Reads .hicurl.env files by searching up the directory tree to automatically resolve relative paths against configured base URLs.

  • Request syntax sugar: Positional arguments map directly to headers (:), query parameters (==), JSON strings (=), typed JSON values (:=), text files (=@), JSON files (:=@), and localhost port shortcuts (:8000).

  • Offline --dry-run: Prints the exact HTTP/1.1 request stream without sending bytes over the network, allowing you to inspect payloads and headers before execution.

  • Code export: Exports configured queries into standard curl commands using -E curl/--curl.

Syntax Examples

# Localhost shorthand (resolves to http://localhost:8000/v1/health)
hicurl :8000/v1/health :status

# Typed JSON payload with response filtering
hicurl post /users name="Alicia" role="admin" age:=28 .id

# Latency and timing metrics
hicurl get /heavy-query :time :time.ttfb

# Embedding local JSON file into request body
hicurl post /post user:=@tests/test_data.json

# Offline dry run mode
hicurl post /users name="Alicia" --dry-run

# Nested subshell query composition
hicurl $(hicurl api.github.com/search/users q==cladam per_page==3 .items.0.url) .bio

Installation

Via curl:

curl -fsSL https://github.com/cladam/hicurl/releases/latest/download/install.sh | sh

Or via hicurl itself:

hicurl https://github.com/cladam/hicurl/releases/latest/download/install.sh | sh

Repository: https://github.com/cladam/hicurl


r/hica • • Jun 02 '26

HML to Markdown

2 Upvotes

HML has the concept of Text Content, which makes it easy to mix prose and attributes.
To highlight how powerful this is, I have created an example that takes a hml file and generates Markdown.

@article(category: "engineering") {
    title: "On Code Stillness"
    author: "Claes Adamsson"

    @body {
        HML lets structured config and prose live in the same file.
        We can embed @em{inline emphasis} or a @link(href: "https://hica.dev"){hyperlink} seamlessly.

        @p(class: "lead") {
            An explicit paragraph node, use it when you need to attach
            attributes or address the paragraph as a distinct tree node.
            For plain paragraph breaks, a blank line is sufficient.
        }
    }
}

Take a look at the example on how to parse the above and generate text with a clean Markdown formatting: to_markdown.hc

This is what it will render, run it with hica run examples/to_markdown.hc

# On Code Stillness
*By Claes Adamsson*

HML lets structured config and prose live in the same file.
We can embed *inline emphasis* or a [hyperlink](https://hica.dev) seamlessly.

An explicit paragraph node, use it when you need to attach
attributes or address the paragraph as a distinct tree node.
For plain paragraph breaks, a blank line is sufficient.