Skip to content
Ilkka Törmä edited this page May 19, 2017 · 1 revision

The design of Husk is greatly inspired by Haskell, which is also the language Husk is implemented in and transpiled to. On the other hand, Husk is a golfing language, and thus intended to be extremely terse.

Functionality

Like Haskell, Husk is a pure functional language. This means that a Husk program is really one function with no side effects, which takes some number of input values and produces an output value. Husk functions are also first class values: functions can be passed as arguments to other functions, and can produce new functions as return values. Husk has an extensive collection combinators that allow functions to be combined in various ways. Indeed, flow control constructs, like for loops and if statements, don't exist in Husk. Instead, you use higher-order functions and recursion.

Type system and overloading

Husk inherits from Haskell a strict type system. Every expression and value has a well-defined type, and types are inferred automatically during compilation. There is no automatic type coercion, so if you try to concatenate a string to an integer, the result is a compilation error.

Strict types may seem like a hindrance in a golfing language. Indeed, Husk is partly an experiment in implementing a golfing language with a Haskell-like type system. Our solution is nondeterministic types. Every built-in function has several implementations, each with a different type. The compiler will try all implementations of each literal until it finds an assignment that results in a well-typed program, which is then transpiled into Haskell and run. The types of the input values are also taken into account. This means that Husk functions are overloaded in the same vein as in many other golfing languages, but the programmer can potentially be even more implicit and have the compiler "guess" the intended meaning of the program.

Lazyness

Like Haskell, Husk is a lazy language: the result values of functions are computed on an as-needed basis. If you divide by zero but never actually use the result, no error is raised. Infinite lists can be passed around and manipulated just like any other values.

Clone this wiki locally