Repository navigation
Release 0.8.3
Changes
Monomorphization
Idris's polymorphic functions and data types previously always lowered to JVM signatures built from Object and java.util.function.Function, so every primitive value crossing a polymorphic boundary was boxed (and unboxed right back). This PR adds a monomorphization pass. When codegen observes a polymorphic function, lambda, or constructor being used at concrete primitive types, it emits an additional specialized version with a primitive descriptor and rewires those call sites to use it.
The original generic versions are always kept and remain the target for genuinely polymorphic call sites, so behavior is unchanged — this is purely a bytecode-level optimization. No source changes, flags, or FFI changes are required.
What gets specialized
1. Functions
primNumShow : (a -> String) -> Prec -> a -> String
Show Int where
showPrec = primNumShow prim__cast_IntStringBefore, the Int call site had to box into the Object parameter:
// only version available: third parameter is Object
static String primNumShow(Function f, Object d, Object x) { ... }
primNumShow(..., ext$0, Integer.valueOf(ext$1)); // box on every callNow a specialized sibling ($sp suffix) is emitted next to the original, and the call site uses it directly:
static String primNumShow(Function f, Object d, Object x) { ... } // kept
static String primNumShow$sp0(Function f, Object d, int x) { ... } // new
primNumShow$sp0(..., ext$0, ext$1); // int flows through unboxed2. Higher-order functions and lambdas
Callbacks no longer have to go through Function.apply(Object)Object. When a lambda's parameter and result are used at primitive types, the backend generates a small typed functional interface and creates the lambda against it:
myMap : (a -> b) -> List a -> List b
myMap f [] = []
myMap f (x :: xs) = f x :: myMap f xs
main = printLn (mySum (myMap (\x => x * 2) [1, 2, 3]))myMap$sp0 takes the callback as a generated Fn$I$I interface with int apply(int), so each element is multiplied without any Integer allocation. Arity-2 callbacks are covered too: zipWith (+) over List Double invokes Fn$D$D$D.apply(DD)D — two doubles in, one double out, zero boxes.
Each typed interface extends java.util.function.Function with a default boxing bridge, so a specialized callback can still escape into generic code (stored in a Maybe, passed to a polymorphic HOF, partially applied) and behaves exactly like before.
3. Data constructors
Constructor cells get specialized classes with unboxed fields. With the example above, the result list's cons cells are CONS$I$L instances holding a raw int head instead of a boxed one — and the same applies to user-defined types: a Tree Double built with primitive payloads is stored in classes with double fields, with a shared family interface so mixed-constructor values (Leaf/Node, Done/Run) dispatch uniformly.
Fix IDE mode
- Fix for
fEOFon stdio: it previously triggered a blocking read, which stalled every ide-mode reply until the next request's bytes arrived (breaking emacs and other ide-mode clients). It now reports the EOF flag with Cfeofsemantics.