--- /dev/null
+package org.simantics.scl.compiler.constants.singletons;
+
+import org.simantics.scl.compiler.constants.FunctionValue;
+import org.simantics.scl.compiler.internal.codegen.references.Val;
+import org.simantics.scl.compiler.internal.codegen.utils.MethodBuilder;
+import org.simantics.scl.compiler.types.TVar;
+import org.simantics.scl.compiler.types.Type;
+import org.simantics.scl.compiler.types.Types;
+import org.simantics.scl.compiler.types.kinds.Kinds;
+
+public class ClassConstant extends FunctionValue {
+
+ private static final TVar A = Types.var(Kinds.STAR);
+ public static final ClassConstant INSTANCE = new ClassConstant();
+
+ private ClassConstant() {
+ super(new TVar[] {A}, Types.NO_EFFECTS, Types.apply(Types.CLASS, A),
+ Types.pred(Types.VEC_COMP, A));
+ }
+
+ @Override
+ public Type applyExact(MethodBuilder mb, Val[] parameters) {
+ mb.push(parameters[0], Types.CLASS);
+ return getReturnType();
+ }
+}
\ No newline at end of file
import org.simantics.scl.compiler.constants.SCLConstant;
import org.simantics.scl.compiler.constants.SCLConstructor;
import org.simantics.scl.compiler.constants.singletons.BindingConstant;
+import org.simantics.scl.compiler.constants.singletons.ClassConstant;
import org.simantics.scl.compiler.constants.singletons.FailFunction;
import org.simantics.scl.compiler.constants.singletons.JustConstant;
import org.simantics.scl.compiler.constants.singletons.NothingConstant;
addValue("freezeMVector", new FreezeMVector());
addValue("setMVector", SetMVector.INSTANCE);
+ StandardTypeConstructor ClassC = new StandardTypeConstructor(Types.CLASS, Kinds.STAR_TO_STAR,
+ TypeDesc.forClass("java/lang/Class"));
+ ClassC.setType(Types.CLASS, A);
+ addTypeDescriptor("Class", ClassC);
+ addValue("classObject", ClassConstant.INSTANCE);
+
// *** fail ***
addValue("fail", FailFunction.INSTANCE).documentation =
public static final TCon TYPEABLE = con(BUILTIN, "Typeable");
public static final TCon SERIALIZABLE = con(BUILTIN, "Serializable");
public static final TCon VEC_COMP = con(BUILTIN, "VecComp");
+ public static final TCon CLASS = con(BUILTIN, "Class");
public static final TCon BINDING = con(BUILTIN, "Binding");
public static final TCon TYPE = con(BUILTIN, "Type");
--- /dev/null
+import "Map" as Map
+import "Vector"
+import "Logging" as LOGGER
+
+importJava "javax.ws.rs.client.Invocation" where
+ data Invocation
+
+ @JavaName invoke
+ invoke_ :: Invocation -> Class a -> <Proc, Exception> a
+
+invoke :: VecComp a => Invocation -> <Proc, Exception> a
+invoke invocation = invoke_ invocation classObject
+
+importJava "javax.ws.rs.client.Invocation$Builder" where
+ data Builder
+
+ header :: Builder -> String -> String -> <Proc> Builder
+ accept :: Builder -> Vector String -> <Proc> Builder
+ cookie :: Builder -> String -> String -> <Proc> Builder
+ build :: Builder -> String -> <Proc> Invocation
+
+importJava "javax.ws.rs.client.WebTarget" where
+ data WebTarget
+
+ path :: WebTarget -> String -> <Proc> WebTarget
+ queryParam :: WebTarget -> String -> Vector String -> <Proc> WebTarget
+ request :: WebTarget -> Vector String -> <Proc> Builder
+
+importJava "javax.ws.rs.client.ClientBuilder" where
+ data ClientBuilder
+
+ @JavaName newBuilder
+ clientBuilder :: <Proc> ClientBuilder
+
+ @JavaName build
+ buildClient :: ClientBuilder -> Client
+
+importJava "javax.ws.rs.client.Client" where
+ data Client
+
+ target :: Client -> String -> <Proc> WebTarget
+ close :: Client -> <Proc> ()
+
+getTextHtmlExample :: String -> Map.T String a -> <Proc, Exception> String
+getTextHtmlExample uri queryParams = do
+ httpClient = buildClient clientBuilder
+ webTarget = target httpClient uri
+ req = request webTarget (vector ["text/html"])
+ invocation = build req "GET"
+ res = invoke invocation
+ close httpClient
+ res
+