]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
(refs #7214) Treat $ exactly like function application 09/509/2
authorHannu Niemistö <hannu.niemisto@iki.fi>
Thu, 11 May 2017 19:54:24 +0000 (22:54 +0300)
committerHannu Niemistö <hannu.niemisto@iki.fi>
Thu, 11 May 2017 20:10:49 +0000 (23:10 +0300)
Converts (f $ p) before type checking to (f p). This slightly changes
the semantics of the language for it is now possible to use $ with
functions like runProc, syncRead etc.

Change-Id: Ida816667a5c9d7623d59ca998a34fe98df5b4732

bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/common/names/Names.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EApply.java

index 1737a0d7d8d7646665283d80eb32740783704aeb..1c4255b46c14ae83b9455fba3afb450a9d5e432e 100644 (file)
@@ -33,12 +33,13 @@ public class Names {
     public static final Name Prelude_bind = Name.create("Prelude", ">>=");
     public static final Name Prelude_build = Name.create("Prelude", "build");
     public static final Name Prelude_concatMap = Name.create("Prelude", "concatMap");
+    public static final Name Prelude_dollar = Name.create("Prelude", "$");
     public static final Name Prelude_elem = Name.create("Prelude", "elem");
     public static final Name Prelude_elemMaybe = Name.create("Prelude", "elemMaybe");
     public static final Name Prelude_emptyList = Name.create("Prelude", "emptyList");
     public static final Name Prelude_foldl = Name.create("Prelude", "foldl");
-    public static final Name Prelude_fromDouble = Name.create("Prelude", "fromDouble");    
-    public static final Name Prelude_fromInteger = Name.create("Prelude", "fromInteger"); 
+    public static final Name Prelude_fromDouble = Name.create("Prelude", "fromDouble");
+    public static final Name Prelude_fromInteger = Name.create("Prelude", "fromInteger");
     public static final Name Prelude_guardList = Name.create("Prelude", "guardList");
     public static final Name Prelude_iterList = Name.create("Prelude", "iterList");
     public static final Name Prelude_mapFirst = Name.create("Prelude", "mapFirst");
index fd5822743432a533e3ec9d5e482adfb2582733b1..501c7f95d3db2c4c52fbba2caa630ee1716bb1f1 100644 (file)
@@ -3,6 +3,7 @@ package org.simantics.scl.compiler.elaboration.expressions;
 import java.util.ArrayList;
 
 import org.simantics.scl.compiler.common.names.Name;
+import org.simantics.scl.compiler.common.names.Names;
 import org.simantics.scl.compiler.constants.NoRepConstant;
 import org.simantics.scl.compiler.elaboration.contexts.ReplaceContext;
 import org.simantics.scl.compiler.elaboration.contexts.SimplificationContext;
@@ -287,12 +288,16 @@ public class EApply extends Expression {
     
     @Override
     public Expression inferType(TypingContext context) {
+        if(parameters.length == 2 && function instanceof EConstant && ((EConstant)function).value.getName() == Names.Prelude_dollar)
+            return new EApply(location, parameters[0], parameters[1]).inferType(context);
         inferType(context, false);
         return this;
     }
     
     @Override
     public Expression checkIgnoredType(TypingContext context) {
+        if(parameters.length == 2 && function instanceof EConstant && ((EConstant)function).value.getName() == Names.Prelude_dollar)
+            return new EApply(location, parameters[0], parameters[1]).inferType(context);
         inferType(context, true);
         if(Types.canonical(getType()) != Types.UNIT)
             return new ESimpleLet(location, null, this, new ELiteral(NoRepConstant.PUNIT));