Idris JVM: Guarding Against Java Null Using Maybe Type
Idris JVM now helps avoiding nulls getting into Idris from FFI calls using Maybe type.
FFI declarations can have Maybe type in any argument position or in the return type.
The above function is an FFI call to Java’s method
static String getProperty(String key).
The method returns a system property value if the property is set otherwise returns null.
With Maybe type in the Idris function’s return type, the Idris function returns Nothing if the returned value is null
otherwise the value is wrapped in Just.
In the above code, the Java method
JOptionPane.showMessageDialog(parentComponent, message)
takes a nullable parent component and a message. If the parent component is null then the message is displayed in a default frame.