From: Hannu Niemistö Date: Thu, 11 May 2017 19:54:24 +0000 (+0300) Subject: (refs #7214) Treat $ exactly like function application X-Git-Tag: v1.29.0~55^2 X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=commitdiff_plain;h=63f6a68f31de96e8e8f31cd99b79c365029aa557 (refs #7214) Treat $ exactly like function application 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 --- diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/common/names/Names.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/common/names/Names.java index 1737a0d7d..1c4255b46 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/common/names/Names.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/common/names/Names.java @@ -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"); diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EApply.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EApply.java index fd5822743..501c7f95d 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EApply.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EApply.java @@ -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));