## Importing functionality from Java Java interfaces and classes can be imported from Java by declaring them inside `importJava` block: ~~~ importJava "java.util.regex.Pattern" where data Pattern importJava "java.util.List" where data List a ~~~ Java methods, constructors and fields can be similarly imported by giving their type annotations in `importJava` block: ~~~ importJava "java.util.regex.Pattern.compile" where @JavaName compile compilePattern :: String -> Pattern @JavaName matcher createMatcher :: Pattern -> String -> Matcher importJava "java.util.regex.Matcher" where data Matcher @JavaName matches matcherMatches :: Matcher -> Boolean matches : Pattern -> String -> Boolean matches pattern text = do matcherMatches (createMatcher pattern text) ~~~ Another example: ~~~ importJava "java.util.ArrayList" where @JavaName "" createArrayList :: () -> List a @JavaName "" createArrayListWithCapacity :: Integer -> List a @JavaName size sizeList :: List a -> Integer @JavaName get getList :: List a -> Integer -> a @JavaName set setList :: List a -> Integer -> a -> () @JavaName add addList :: List a -> a -> Boolean ~~~ Java constructor is referred with `""`. If Java method name and SCL name matches the annotation `@JavaName` can be left out. Java import mechanism tries to be quite flexible. It provides some arguments based on the effects the function has. It also ignores the return value of the Java method if the return type is `()` in SCL. A major functionality currently still missing is the ability to create new implementations of existing Java interfaces in SCL code or extend an existing class. This can be worked around currently by writing new implementations in Java. ## Relational sublanguage * Select, when, enforce * Transformations ## Other language features * Defining data types * Defining type classes * Defining effects * Restricted imports * Documentation strings * Private definitions * Binary operator precedence