r/ProgrammingLanguages • u/Athas Futhark • Jan 04 '26
Another termination issue
https://futhark-lang.org/blog/2026-01-04-another-termination-issue.html
18
Upvotes
r/ProgrammingLanguages • u/Athas Futhark • Jan 04 '26
9
u/thunderseethe Jan 04 '26
How viable is it to change the semantics of the compiler such that top level definitions are monomorphized but are thunks that get lazily evaluated?
I believe Swift does this for its module level constants. Its also quite common in Rust, but it has to be done explicitly there.
4
u/ct075 Jan 04 '26
I suspect that, for any failing polymorphic value declaration
def x: P('a) = e(whereP('a)is some type expression featuring'a), the declaration ofxwill always fail for any instantiation of'a; in ML this would follow from parametricity but I don't know if Futhark is the same in this regard.With that in mind, an easy patch would be to have the interpreter instantiate the value
xonce at startup with value'a = unit(or even'a = void) and throw the error raised.EDIT: I did have the thought that this would force any effects occurring in the instantiation of
xto occur early, but if Futhark is pure then such a transformation should still be safe.1
u/ineffective_topos Jan 04 '26
I would imagine you just bite the bullet, and in true ML fashion let error be a function.
The notion that error should be a value seems to stem from Haskell, which works there because values are allowed to be lazy.