minigrace
Version:
A compiler for the Grace programming language
736 lines • 186 kB
JavaScript
let gracecode_basicTypesBundle_sourceFile = "/Users/black/Development/mg/gracelang/minigrace/basicTypesBundle.grace";
let gracecode_basicTypesBundle_sha256 = "a92f82688bb1cc8115ef137253879a01af7417b0271f4c86a9044d2a72bb6f2c";
let gracecode_basicTypesBundle_minigraceRevision = "b57591d29fc5ee5270d114920bf671367b8c3ecb";
let gracecode_basicTypesBundle_minigraceGeneration = "5171";
if (typeof gctCache !== "undefined")
gctCache["basicTypesBundle"] = "dialect:\nfreshScopes:\n $101 trait\nmodules:\n intrinsic\npath:\n /Users/black/Development/mg/gracelang/minigrace/basicTypesBundle.grace\nscope:$100:\n asDebugString String (go) $scope_string\n asString String (go) $scope_string\n basicAsString String (go) $scope_string\n isMe(1) Boolean (go) $scope_boolean\n myIdentityHash Number (go) $scope_number\n open Unknown (mth) $101\nscope:$101:\n Binding type\n Boolean type\n Collection type\n CollectionFactory type\n Done type\n Enumerable type\n EqualityObject type\n ExceptionKind type\n ExceptionPacket type\n Function0 type\n Function1 type\n Function2 type\n Function3 type\n Interface type\n Iterator type\n None type\n Number type\n Object type\n Pattern type\n Point type\n Predicate0 type\n Predicate1 type\n Predicate2 type\n Predicate3 type\n Procedure0 type\n Procedure1 type\n Procedure2 type\n Procedure3 type\n SelfType type\n Sequence type\n Sequenceable type\n Signature type\n Sink type\n String type\n Type type\n asDebugString String (go) $scope_string\n asString String (go) $scope_string\n basicAsString String (go) $scope_string\n isMe(1) Boolean (go) $scope_boolean\n myIdentityHash Number (go) $scope_number\nself:\n $100\ntypedec:$101.Binding:\n type Binding\u27e6K, T\u27e7 = EqualityObject & interface {\n key \u2192 K\n value \u2192 T}\ntypedec:$101.Boolean:\n type Boolean = EqualityObject & interface {\n not \u2192 Boolean\n prefix! \u2192 Boolean\n &&(other:Predicate0 | Boolean) \u2192 Boolean\n ||(other:Predicate0 | Boolean) \u2192 Boolean\n ifTrue(action:Function0\u27e6T\u27e7) \u2192 Done forall T\n ifFalse(action:Function0\u27e6T\u27e7) \u2192 Done forall T\n ifTrue(trueAction:Function0\u27e6T\u27e7)ifFalse(falseAction:Function0\u27e6F\u27e7) \u2192 T | F forall T, F\n ifFalse(falseAction:Function0\u27e6F\u27e7)ifTrue(trueAction:Function0\u27e6T\u27e7) \u2192 T | F forall T, F\n asString \u2192 String\n asDebugString \u2192 Unknown\n hash \u2192 Number}\ntypedec:$101.Collection:\n type Collection\u27e6T\u27e7 = Object & interface {\n iterator \u2192 Iterator\u27e6T\u27e7\n isEmpty \u2192 Boolean\n size \u2192 Number\n sizeIfUnknown(action:Function0\u27e6Number\u27e7)\n ==(other) \u2192 Boolean\n \u2260(other) \u2192 Boolean\n first \u2192 T\n do(body:Procedure1\u27e6T\u27e7) \u2192 Done\n do(body:Procedure1\u27e6T\u27e7)separatedBy(separator:Procedure0) \u2192 Done\n ++(other:Collection\u27e6T\u27e7) \u2192 Collection\u27e6T\u27e7\n fold(binaryFunction:Function2\u27e6T, T, T\u27e7)startingWith(initial:T) \u2192 T\n map\u27e6U\u27e7(function:Function1\u27e6T, U\u27e7) \u2192 Collection\u27e6U\u27e7\n filter(condition:Predicate1\u27e6T\u27e7) \u2192 Collection\u27e6T\u27e7\n contains(elem:T) \u2192 Boolean\n anySatisfy(condition:Predicate1\u27e6T\u27e7) \u2192 Boolean\n allSatisfy(condition:Predicate1\u27e6T\u27e7) \u2192 Boolean\n >>(target:Sink\u27e6T\u27e7) \u2192 Collection\u27e6T\u27e7\n <<(source:Collection\u27e6T\u27e7) \u2192 Collection\u27e6T\u27e7}\ntypedec:$101.CollectionFactory:\n type CollectionFactory\u27e6T\u27e7 = Object & interface {\n empty \u2192 Collection\u27e6T\u27e7\n with(element:T) \u2192 Collection\u27e6T\u27e7\n withAll(source:Collection\u27e6T\u27e7) \u2192 Collection\u27e6T\u27e7\n <<(source:Collection\u27e6T\u27e7) \u2192 Collection\u27e6T\u27e7}\ntypedec:$101.Done:\n type Done = interface {\n asString \u2192 String\n asDebugString \u2192 String}\ntypedec:$101.Enumerable:\n type Enumerable\u27e6T\u27e7 = Collection\u27e6T\u27e7 & interface {\n values \u2192 Collection\u27e6T\u27e7\n keysAndValuesDo(action:Function2\u27e6Number, T, Object\u27e7) \u2192 Done\n sortedBy(comparison:Function2\u27e6T, T, Number\u27e7) \u2192 SelfType\n sorted \u2192 SelfType}\ntypedec:$101.EqualityObject:\n type EqualityObject = Object & interface {\n ::(o:Object) \u2192 Binding\n ==(other:Object) \u2192 Boolean\n \u2260(other:Object) \u2192 Boolean\n hash \u2192 Number\n prefix== \u2192 Pattern\n prefix\u2260 \u2192 Pattern}\ntypedec:$101.ExceptionKind:\n type ExceptionKind = EqualityObject & Pattern & interface {\n refine(parentKind:ExceptionKind) \u2192 ExceptionKind\n parent \u2192 ExceptionKind\n name \u2192 String\n raise(message:String) \u2192 Done\n raise(message:String)with(argument:Object) \u2192 Done}\ntypedec:$101.ExceptionPacket:\n type ExceptionPacket = Object & interface {\n exception \u2192 ExceptionKind\n message \u2192 String\n data \u2192 Object\n line \u2192 Number\n moduleName \u2192 String\n backtrace \u2192 Sequence\u27e6String\u27e7\n printBacktrace \u2192 Done\n printBacktraceSkippingModules(skipable:Collection) \u2192 Done\n reraise \u2192 None}\ntypedec:$101.Function0:\n type Function0\u27e6ResultT\u27e7 = Object & interface {\n apply \u2192 ResultT}\ntypedec:$101.Function1:\n type Function1\u27e6ArgT1, ResultT\u27e7 = Object & interface {\n apply(a1:ArgT1) \u2192 ResultT\n matches(a1:Object) \u2192 Boolean}\ntypedec:$101.Function2:\n type Function2\u27e6ArgT1, ArgT2, ResultT\u27e7 = Object & interface {\n apply(a1:ArgT1, a2:ArgT2) \u2192 ResultT\n matches(a1:Object, a2:Object) \u2192 Boolean}\ntypedec:$101.Function3:\n type Function3\u27e6ArgT1, ArgT2, ArgT3, ResultT\u27e7 = Object & interface {\n apply(a1:ArgT1, a2:ArgT2, a3:ArgT3) \u2192 ResultT\n matches(a1:Object, a2:Object, a3:Object) \u2192 Boolean}\ntypedec:$101.Interface:\n type Interface = Type & interface {\n methodNames \u2192 Sequence\u27e6String\u27e7\n methodAt(canonicalName:String) \u2192 Signature}\ntypedec:$101.Iterator:\n type Iterator\u27e6T\u27e7 = interface {\n hasNext \u2192 Boolean\n next \u2192 T}\ntypedec:$101.None:\n type None = intrinsic.noneType\ntypedec:$101.Number:\n type Number = EqualityObject & interface {\n @(other:Number) \u2192 Point\n ^(n:Object) \u2192 Number\n sqrt \u2192 Number\n +(n:Object) \u2192 Number\n -(n:Object) \u2192 Number\n *(n:Object) \u2192 Number\n /(n:Object) \u2192 Number\n %(n:Object) \u2192 Number\n \u00f7(n:Object) \u2192 Number\n ..(last:Number) \u2192 Sequence\u27e6Number\u27e7\n downTo(last:Number) \u2192 Sequence\u27e6Number\u27e7\n <(other:Number) \u2192 Boolean\n \u2264(other:Number) \u2192 Boolean\n >(other:Number) \u2192 Boolean\n \u2265(other:Number) \u2192 Boolean\n prefix- \u2192 Number\n compare(other:Number) \u2192 Number\n inBase(base:Number) \u2192 String\n asString \u2192 String\n asDebugString \u2192 String\n asStringDecimals(d) \u2192 String\n isInteger \u2192 Boolean\n truncated \u2192 Number\n rounded \u2192 Number\n floor \u2192 Number\n ceiling \u2192 Number\n abs \u2192 Number\n sgn \u2192 Number\n isNaN \u2192 Boolean\n isEven \u2192 Boolean\n isOdd \u2192 Boolean\n sin \u2192 Number\n cos \u2192 Number\n tan \u2192 Number\n asin \u2192 Number\n acos \u2192 Number\n atan \u2192 Number\n lg \u2192 Number\n ln \u2192 Number\n exp \u2192 Number\n log10 \u2192 Number\n prefix> \u2192 Pattern\n prefix\u2265 \u2192 Pattern\n prefix< \u2192 Pattern\n prefix\u2264 \u2192 Pattern\n prefix== \u2192 Pattern}\ntypedec:$101.Object:\n type Object = interface {\n asString \u2192 String\n asDebugString \u2192 String}\ntypedec:$101.Pattern:\n type Pattern = Object & interface {\n matches(value:Object) \u2192 Boolean\n &(other:Pattern) \u2192 Pattern\n |(other:Pattern) \u2192 Pattern\n prefix\u00ac \u2192 Pattern\n isType \u2192 Boolean}\ntypedec:$101.Point:\n type Point = EqualityObject & interface {\n x \u2192 Number\n y \u2192 Number\n ==(other:outer.Object) \u2192 Boolean\n +(other:Point | Number) \u2192 Point\n -(other:Point | Number) \u2192 Point\n prefix- \u2192 Point\n *(factor:Number) \u2192 Point\n /(factor:Number) \u2192 Point\n length \u2192 Number\n distanceTo(other:Point) \u2192 Number\n dot(other:Point) \u2192 Number\n \u22c5(other:Point) \u2192 Number\n norm \u2192 Point\n reverseTimesNumber(n:Number) \u2192 Point\n reversePlusNumber(n:Number) \u2192 Point\n reverseDivideNumber(n:Number) \u2192 Point\n reverseMinusNumber(n:Number) \u2192 Point}\ntypedec:$101.Predicate0:\n type Predicate0 = Function0\u27e6Boolean\u27e7\ntypedec:$101.Predicate1:\n type Predicate1\u27e6ArgT1\u27e7 = Function1\u27e6ArgT1, Boolean\u27e7\ntypedec:$101.Predicate2:\n type Predicate2\u27e6ArgT1, ArgT2\u27e7 = Function2\u27e6ArgT1, ArgT2, Boolean\u27e7\ntypedec:$101.Predicate3:\n type Predicate3\u27e6ArgT1, ArgT2, ArgT3\u27e7 = Function3\u27e6ArgT1, ArgT2, ArgT3, Boolean\u27e7\ntypedec:$101.Procedure0:\n type Procedure0 = Function0\u27e6Done\u27e7\ntypedec:$101.Procedure1:\n type Procedure1\u27e6ArgT1\u27e7 = Function1\u27e6ArgT1, Done\u27e7\ntypedec:$101.Procedure2:\n type Procedure2\u27e6ArgT1, ArgT2\u27e7 = Function2\u27e6ArgT1, ArgT2, Done\u27e7\ntypedec:$101.Procedure3:\n type Procedure3\u27e6ArgT1, ArgT2, ArgT3\u27e7 = Function3\u27e6ArgT1, ArgT2, ArgT3, Done\u27e7\ntypedec:$101.SelfType:\n type SelfType = Unknown\ntypedec:$101.Sequence:\n type Sequence\u27e6T\u27e7 = EqualityObject & Sequenceable\u27e6T\u27e7\ntypedec:$101.Sequenceable:\n type Sequenceable\u27e6T\u27e7 = Enumerable\u27e6T\u27e7 & interface {\n size \u2192 Number\n at(n:Number) \u2192 T\n at\u27e6W\u27e7(n:Number)ifAbsent(action:Function0\u27e6W\u27e7) \u2192 T | W\n indices \u2192 Sequence\u27e6Number\u27e7\n keys \u2192 Sequence\u27e6Number\u27e7\n second \u2192 T\n third \u2192 T\n fourth \u2192 T\n fifth \u2192 T\n last \u2192 T\n indexOf\u27e6W\u27e7(elem:T)ifAbsent(action:Function0\u27e6W\u27e7) \u2192 Number | W\n indexOf(elem:T) \u2192 Number\n reversed \u2192 Sequence\u27e6T\u27e7}\ntypedec:$101.Signature:\n type Signature = interface {\n name \u2192 String\n typeParameterNames \u2192 Sequence\u27e6String\u27e7\n parameterNames \u2192 Sequence\u27e6String\u27e7\n parameterTypes \u2192 Sequence\u27e6Type\u27e7\n returnType \u2192 Type}\ntypedec:$101.Sink:\n type Sink\u27e6T\u27e7 = interface {\n <<(source:Collection\u27e6T\u27e7) \u2192 Collection\u27e6T\u27e7}\ntypedec:$101.String:\n type String = EqualityObject & interface {\n reverseTimesNumber(n:Number) \u2192 String\n *(n:Number) \u2192 String\n ++(other:Object) \u2192 String\n <(other:String)\n \u2264(other:String)\n >(other:String)\n \u2265(other:String)\n at(index:Number) \u2192 String\n first \u2192 String\n second \u2192 String\n third \u2192 String\n fourth \u2192 String\n fifth \u2192 String\n last \u2192 String\n allSatisfy(p:Predicate1\u27e6String\u27e7) \u2192 Boolean\n anySatisfy(p:Predicate1\u27e6String\u27e7) \u2192 Boolean\n asDebugString \u2192 String\n asLower \u2192 String\n asNumber \u2192 Number\n asUpper \u2192 String\n do(action:Procedure1\u27e6String\u27e7) \u2192 Done\n do(action:Procedure1\u27e6String\u27e7)separatedBy(sep:Procedure0) \u2192 Done\n capitalized \u2192 String\n compare(other:String) \u2192 Number\n contains(other:String) \u2192 Boolean\n endsWith(possibleSuffix:String)\n filter(predicate:Function1\u27e6String, Boolean\u27e7) \u2192 String\n fold\u27e6U\u27e7(binaryFunction:Function2\u27e6U, String, U\u27e7)startingWith(initial:U) \u2192 U\n indexOf(pattern:String) \u2192 Number\n indexOf\u27e6W\u27e7(pattern:String)ifAbsent(absent:Function0\u27e6W\u27e7) \u2192 Number | W\n indexOf(pattern:String)startingAt(offset) \u2192 Number\n indexOf\u27e6W\u27e7(pattern:String)startingAt(offset)ifAbsent(action:Function0\u27e6W\u27e7) \u2192 Number | W\n indices \u2192 Sequence\u27e6Number\u27e7\n keys \u2192 Sequence\u27e6Number\u27e7\n isEmpty \u2192 Boolean\n iterator \u2192 Iterator\u27e6String\u27e7\n keysAndValuesDo(action:Function2\u27e6Number, String, Done\u27e7) \u2192 Done\n lastIndexOf(sub:String) \u2192 Number\n lastIndexOf(sub:String)startingAt(offset) \u2192 Number\n lastIndexOf\u27e6W\u27e7(sub:String)ifAbsent(absent:Function0\u27e6W\u27e7) \u2192 Number | W\n lastIndexOf\u27e6W\u27e7(sub:String)startingAt(offset)ifAbsent(action:Function0\u27e6W\u27e7) \u2192 Number | W\n map\u27e6U\u27e7(function:Function1\u27e6String, U\u27e7) \u2192 Collection\u27e6U\u27e7\n ord \u2192 Number\n replace(pattern:String)with(new:String) \u2192 String\n size \u2192 Number\n sizeIfUnknown\u27e6W\u27e7(action:Procedure0\u27e6W\u27e7) \u2192 Number\n split(splitter:String) \u2192 Sequence\u27e6String\u27e7\n startsWith(possiblePrefix:String) \u2192 Boolean\n startsWithDigit \u2192 Boolean\n startsWithLetter \u2192 Boolean\n startsWithPeriod \u2192 Boolean\n startsWithSpace \u2192 Boolean\n substringFrom(start:Number)size(max:Number) \u2192 String\n substringFrom(start:Number)to(stop:Number) \u2192 String\n substringFrom(start:Number) \u2192 String\n trim \u2192 String\n quoted \u2192 String\n >>(target:Sink\u27e6String\u27e7) \u2192 Collection\n <<(source:Collection\u27e6String\u27e7) \u2192 String\n prefix< \u2192 Pattern\n prefix> \u2192 Pattern\n prefix\u2264 \u2192 Pattern\n prefix\u2265 \u2192 Pattern}\ntypedec:$101.Type:\n type Type = EqualityObject & interface {\n name \u2192 String\n typeParameterNames \u2192 Sequence\u27e6String\u27e7\n isNone \u2192 Boolean\n matches(value:Object) \u2192 Boolean\n &(other:Type) \u2192 Type\n |(other:Type) \u2192 Type\n ==(other:Type) \u2192 Boolean\n \u2260(other:Type) \u2192 Boolean\n -(other:Interface) \u2192 Interface\n hash \u2192 Number\n interfaces \u2192 Sequence\u27e6Interface\u27e7\n isType \u2192 Boolean\n isInterface \u2192 Boolean\n prefix\u00ac \u2192 Pattern}\ntypes:\n $101.Binding\n $101.Boolean\n $101.Collection\n $101.CollectionFactory\n $101.Done\n $101.Enumerable\n $101.EqualityObject\n $101.ExceptionKind\n $101.ExceptionPacket\n $101.Function0\n $101.Function1\n $101.Function2\n $101.Function3\n $101.Interface\n $101.Iterator\n $101.None\n $101.Number\n $101.Object\n $101.Pattern\n $101.Point\n $101.Predicate0\n $101.Predicate1\n $101.Predicate2\n $101.Predicate3\n $101.Procedure0\n $101.Procedure1\n $101.Procedure2\n $101.Procedure3\n $101.SelfType\n $101.Sequence\n $101.Sequenceable\n $101.Signature\n $101.Sink\n $101.String\n $101.Type\n";
if (typeof originalSourceLines !== "undefined") {
originalSourceLines["basicTypesBundle"] = [
"dialect \"none\"",
"import \"intrinsic\" as intrinsic",
"",
"trait open {",
"",
" type None = intrinsic.noneType // the interface type with all possile methods",
"",
" type Type = EqualityObject & interface {",
" // a type is a disjunction of interfaces",
" name → String // the name of this type",
" typeParameterNames → Sequence⟦String⟧",
" isNone → Boolean // true for the type None, otherwise false",
" matches (value:Object) → Boolean",
" & (other:Type) → Type // answers the join (Self & other)",
" | (other:Type) → Type // answers the variant type (Self | other)",
" // :> (other:Type) → Boolean // other conforms to self ToDo: implement this!",
" // <: (other:Type) → Boolean // self conforms to other ToDo: implement this!",
" // :=: (other:Type) → Boolean // (self <: other) && (other :> self) ToDo: implement this!",
" == (other:Type) → Boolean // object identity",
" ≠ (other:Type) → Boolean // object non-identity",
" - (other:Interface) → Interface // the type that is like self,",
" // but excluding other.methodNames from all self's interfaces",
" hash → Number",
" interfaces → Sequence⟦Interface⟧",
" isType → Boolean // answers true (and false for patterns that are not types)",
" isInterface → Boolean // answers true for interface types (and false other types)",
" prefix ¬ → Pattern // answers a pattern that's the inverse of this type",
" }",
"",
" type Interface = Type & interface {",
" // An interface is also a type: the type with self as its sole interface.",
" // Hence, its `interfaces` method must answer [ self ]",
" methodNames → Sequence⟦String⟧ // sorted sequence of the canonical",
" // names of the methods in this interface",
" methodAt(canonicalName:String) → Signature",
" // argument is the canonical name of a method; answers its signature",
" }",
"",
" type Signature = interface {",
" name → String // the canonical name of the method",
" typeParameterNames → Sequence⟦String⟧ // the names of the type parameters",
" parameterNames → Sequence⟦String⟧ // the names of the parameters, in order",
" parameterTypes → Sequence⟦Type⟧ // the types of the parameters, in order",
" returnType → Type // the type of the result",
" }",
"",
" type Object = interface {",
" asString → String",
" asDebugString → String",
" }",
"",
" type Done = interface {",
" asString → String",
" asDebugString → String",
" }",
"",
" type Boolean = EqualityObject & interface {",
" not → Boolean",
" prefix ! → Boolean",
" // the negation of self",
"",
" && (other: Predicate0 | Boolean) → Boolean",
" // returns true when self and other are both true",
"",
" || (other: Predicate0 | Boolean) → Boolean",
" // returns true when either self or other (or both) are true",
"",
" ifTrue (action:Function0⟦T⟧) → Done forall T",
" // if self is true, executes action",
" ifFalse (action:Function0⟦T⟧) → Done forall T",
" // if self is false, executes action",
"",
" ifTrue(trueAction:Function0⟦T⟧) ifFalse(falseAction:Function0⟦F⟧) → T | F forall T, F",
" // if self is true, executes trueAction; otherewise, executes falseAction.",
" // Answers the result of the action that was executed",
"",
" ifFalse(falseAction:Function0⟦F⟧) ifTrue(trueAction:Function0⟦T⟧) → T | F forall T, F",
" // if self is false, executes falseAction; otherewise, executes trueAction.",
" // Answers the result of the action that was executed",
"",
" asString → String",
" asDebugString → Unknown",
" // answers thes string \"true\" or \"false\"",
"",
" hash → Number",
" // the hash of this boolean; true.hash ≠ false.hash",
" }",
"",
" type Pattern = Object & interface {",
" matches(value:Object) → Boolean",
" & (other:Pattern) → Pattern",
" | (other:Pattern) → Pattern",
" prefix ¬ → Pattern",
" isType → Boolean",
" }",
"",
" type Binding⟦K,T where T <: EqualityObject⟧ = EqualityObject & interface {",
" key → K",
" value → T",
" }",
"",
" type EqualityObject = Object & interface {",
" ::(o:Object) → Binding",
" ==(other:Object) → Boolean",
" ≠(other:Object) → Boolean",
" hash → Number",
" prefix == → Pattern",
" prefix ≠ → Pattern",
" }",
"",
" type ExceptionKind = EqualityObject & Pattern & interface {",
" refine (parentKind:ExceptionKind) → ExceptionKind",
" parent → ExceptionKind",
" name → String",
" raise (message:String) → Done",
" raise (message:String) with (argument:Object) → Done",
" }",
"",
" type ExceptionPacket = Object & interface {",
" exception → ExceptionKind // the exceptionKind that raised this exception.",
" message → String // the message provided when this exception was raised.",
"",
" data → Object // the data object associated with this exception",
" // when it was raised, if there was one. Otherwise,",
" // the string \"no data\".",
"",
" line → Number // the source-code line of the raise request",
" // that created this exception.",
"",
" moduleName → String // the name of the module containing the raise",
" // request that created this exception.",
"",
" backtrace → Sequence⟦String⟧",
" // a description of the call stack at the time that this exception was raised.",
" // backtrace.first is the initial execution environment; backtrace.last is the",
" // context that raised the exception.",
"",
" printBacktrace → Done // writes a readable description of this",
" // exceptionPacket and its backtrace to io.error",
"",
" printBacktraceSkippingModules(skipable:Collection) → Done",
" // like printBacktrace, but omiting those stackframes",
" // representing modules in skipable",
"",
" reraise → None // raise this exceptionPacket again",
" }",
"",
" type Function0⟦ResultT⟧ = Object & interface {",
" apply → ResultT // Function with no arguments and a result of type ResultT",
" }",
" type Function1⟦ArgT1, ResultT⟧ = Object & interface {",
" apply(a1:ArgT1) → ResultT // Function with argument a1 of type ArgT1,",
" // and a result of type ResultT",
" matches(a1:Object) → Boolean // answers true if a1 <: ArgT1",
" }",
" type Function2⟦ArgT1, ArgT2, ResultT⟧ = Object & interface {",
" apply(a1:ArgT1, a2:ArgT2) → ResultT",
" // Function with arguments of types ArgT1 and ArgT2, and a result of type ResultT",
" matches(a1:Object, a2:Object) → Boolean",
" // answers true if a1 <: ArgT1 and a2 <: ArgT2",
" }",
" type Function3⟦ArgT1, ArgT2, ArgT3, ResultT⟧ = Object & interface {",
" apply(a1:ArgT1, a2:ArgT2, a3:ArgT3) → ResultT",
" matches(a1:Object, a2:Object, a3:Object) → Boolean",
" // answers true if a1 <: ArgT1 and a2 <: ArgT2 and a3 :< ArgT3",
" }",
"",
" // Procedures are functions that have no result (oterh than Done)",
" type Procedure0 = Function0⟦Done⟧",
" // Function with no arguments and no result",
" type Procedure1⟦ArgT1⟧ = Function1⟦ArgT1, Done⟧",
" // Function with 1 argument of type ArgT1, and no result",
" type Procedure2⟦ArgT1, ArgT2⟧ = Function2⟦ArgT1, ArgT2, Done⟧",
" // Function with 2 arguments of types ArgT1 and ArgT2, and no result",
" type Procedure3⟦ArgT1, ArgT2, ArgT3⟧ = Function3⟦ArgT1, ArgT2, ArgT3, Done⟧",
"",
" // Predictates are functions that return a Boolean",
" type Predicate0 = Function0⟦Boolean⟧",
" // Function with no arguments returning Boolean",
" type Predicate1⟦ArgT1⟧ = Function1⟦ArgT1, Boolean⟧",
" // Function with 1 argument of type ArgT1, returning Boolean",
" type Predicate2⟦ArgT1, ArgT2⟧ = Function2⟦ArgT1, ArgT2, Boolean⟧",
" // Function with 2 arguments of types ArgT1 and ArgT2, returning Boolean",
" type Predicate3⟦ArgT1, ArgT2, ArgT3⟧ = Function3⟦ArgT1, ArgT2, ArgT3, Boolean⟧",
" // Function with 3 arguments of types ArgT1, ArgT2, and ArgT3, returning Boolean",
"",
" type String = EqualityObject & interface {",
" reverseTimesNumber(n:Number) → String",
" // answers self * n. (Used by numbers to implement number * String)",
"",
" * (n: Number) → String",
" // returns a string that contains n repetitions of self, so \"Abc\" * 3 = \"AbcAbcAbc\"",
"",
" ++(other: Object) → String",
" // returns a string that is the concatenation of self and other.asString",
"",
" < (other: String)",
" // true if self precedes other lexicographically",
"",
" <= (other: String)",
" // (self == other) || (self < other)",
"",
" > (other: String)",
" // true if self follows other lexicographically",
"",
" >= (other: String)",
" // (self == other) || (self > other)",
"",
" at(index: Number) → String",
" // returns the character in position index (as a string of size 1); index must be an integer in",
" // the range 1..size",
"",
" first → String",
" // returns the first character of self, as a String of size 1; self must not be empty",
"",
" second → String",
" // returns the second character of self, as a String of size 1; requires self.size ≥ 2",
"",
" third → String",
" // returns the third character of self, as a String of size 1; requires self.size ≥ 3",
"",
" fourth → String",
" // returns the fourth character of self, as a String of size 1; requires self.size ≥ 4",
"",
" fifth → String",
" // returns the fifth character of self, as a String of size 1; requires self.size ≥ 5",
"",
" last → String",
" // returns the last character of self, as a String of size 1; self must not be empty",
"",
" allSatisfy(p:Predicate1⟦String⟧) → Boolean",
" // answers true iff all the characters in self satisfy the predicate p",
"",
" anySatisfy(p:Predicate1⟦String⟧) → Boolean",
" // answers true iff any one of the characters in self satisfies the predicate p",
"",
" asDebugString → String",
" // returns self enclosed in quotes, and with embedded special characters quoted. See also quoted.",
"",
" asLower → String",
" // returns a string like self, except that all letters are in lower case",
"",
" asNumber → Number",
" // attempts to parse self as a number; returns that number, or NaN if it can't.",
"",
" asUpper → String",
" // returns a string like self, except that all letters are in upper case",
"",
" do(action:Procedure1⟦String⟧) → Done",
" // applies action to each character of self.",
"",
" do(action:Procedure1⟦String⟧) separatedBy(sep:Procedure0) → Done",
" // applied action to each character of self, and applies sep between actions.",
"",
" capitalized → String",
" // returns a string like self, except that the initial letters of all words are in upper case",
"",
" compare (other:String) → Number",
" // a three-way comparison: -1 if (self < other), 0 if (self == other), and +1 if (self > other).",
" // This is useful when writing a comparison function for sortBy",
"",
" contains (other:String) → Boolean",
" // returns true if other is a substring of self",
"",
" endsWith (possibleSuffix: String)",
" // true if self ends with possibleSuffix",
"",
" filter (predicate: Function1⟦String,Boolean⟧) → String",
" // returns the String containing those characters of self for which predicate returns true",
"",
" fold⟦U⟧ (binaryFunction: Function2⟦U,String,U⟧) startingWith(initial: U) → U",
" // performs a left fold of binaryFunction over self, starting with initial.",
" // For example, fold {a, b → a + b.ord} startingWith 0 will compute the sum",
" // of the ords of the characters in self",
"",
" indexOf (pattern:String) → Number",
" // returns the leftmost index at which pattern appears in self, or 0 if it is not there.",
"",
" indexOf⟦W⟧ (pattern:String) ifAbsent (absent:Function0⟦W⟧) → Number | W",
" // returns the leftmost index at which pattern appears in self; applies absent if it is not there.",
"",
" indexOf (pattern:String) startingAt (offset) → Number",
" // like indexOf(pattern), but returns the smallest index ≥ offset, or 0 if pattern is not found.",
"",
" indexOf⟦W⟧ (pattern:String) startingAt(offset) ifAbsent (action:Function0⟦W⟧) → Number | W",
" // like the above, except that it returns the result of applying action if there is no such index.",
"",
" indices → Sequence⟦Number⟧",
" keys → Sequence⟦Number⟧",
" // an object representing the range of indices of self (1..self.size).",
"",
" isEmpty → Boolean",
" // true if self is the empty string",
"",
" iterator → Iterator⟦String⟧",
" // an iterator over the characters of self",
"",
" keysAndValuesDo(action:Function2⟦Number, String, Done⟧) → Done",
" // applies action to two arguments for each character in self: the key (index) of the character,",
" // and the character itself.",
"",
" lastIndexOf (sub:String) → Number",
" // returns the rightmost index at which sub appears in self, or 0 if it is not there.",
"",
" lastIndexOf (sub:String) startingAt (offset) → Number",
" // like the above, except that it returns the rightmost index ≤ offset.",
"",
" lastIndexOf⟦W⟧ (sub:String) ifAbsent (absent:Function0⟦W⟧) → Number | W",
" // returns the rightmost index at which sub appears in self; applies absent if it is not there.",
"",
" lastIndexOf⟦W⟧ (sub:String)",
" startingAt (offset)",
" ifAbsent (action:Function0⟦W⟧) → Number | W",
" // like the above, except that it returns the rightmost index ≤ offset.",
"",
" map⟦U⟧ (function:Function1⟦String,U⟧) → Collection⟦U⟧",
" // returns a Collection containing the results of successive applications of function to the",
" // individual characters of self. Note that the result is not a String, even if type U happens to be String.",
" // If a String is desired, use fold (_) startingWith \"\" with a function that concatenates.",
"",
" ord → Number",
" // a numeric representation of the first character of self, or NaN if self is empty.",
"",
" replace (pattern:String) with (new:String) → String",
" // a string like self, but with all occurrences of pattern replaced by new",
"",
" size → Number",
" // returns the size of self, i.e., the number of characters it contains.",
"",
" sizeIfUnknown⟦W⟧(action:Procedure0⟦W⟧) → Number",
" // returns the size of self, which is always known, so action is never executed.",
"",
" split(splitter:String) → Sequence⟦String⟧",
" // answers a sequence of substrings of self, split before and after each",
" // occurrence of splitter in self. If self is empty, the result sequence",
" // will also be empty; otherwise, if self does not contain splitter,",
" // the result sequence will be of size 1.",
"",
" startsWith (possiblePrefix:String) → Boolean",
" // true when possiblePrefix is a prefix of self",
"",
" startsWithDigit → Boolean",
" // true if the first character of self is a (Unicode) digit.",
"",
" startsWithLetter → Boolean",
" // true if the first character of self is a (Unicode) letter",
"",
" startsWithPeriod → Boolean",
" // true if the first character of self is a period",
"",
" startsWithSpace → Boolean",
" // true if the first character of self is a (Unicode) space.",
"",
" substringFrom (start:Number) size (max:Number) → String",
" // returns the substring of self starting at index start and of length max characters,",
" // or extending to the end of self if that is less than max. If start = self.size + 1 or",
" // stop < start, the empty string is returned. If start is outside the range",
" // 1..self.size+1, BoundsError is raised.",
"",
" substringFrom (start:Number) to (stop:Number) → String",
" // returns the substring of self starting at index start and extending",
" // either to the end of self, or to stop. If start = self.size + 1, or",
" // stop < start, the empty string is returned. If start is outside the range",
" // 1..self.size+1, BoundsError is raised.",
"",
" substringFrom (start:Number) → String",
" // returns the substring of self starting at index start and extending",
" // to the end of self. If start = self.size + 1, the empty string is returned.",
" // If start is outside the range 1..self.size+1, BoundsError is raised.",
"",
" trim → String",
" // a string like self except that leading and trailing spaces are omitted.",
"",
" quoted → String",
" // returns a quoted version of self, with internal characters like \" and \\ and newline escaped,",
" // but without surrounding quotes. See also asDebugString",
"",
" >> (target:Sink⟦String⟧) → Collection",
" // returns target << self",
"",
" << (source:Collection⟦String⟧) → String",
" // returns a string containing me, followed in order by the elements of source.",
"",
" prefix < → Pattern // the pattern matching strings < self",
" prefix > → Pattern // the pattern matching strings > self",
" prefix ≤ → Pattern // the pattern matching strings ≤ self",
" prefix ≥ → Pattern // the pattern matching strings ≥ self",
" // prefix == is defined in the equality trait",
" }",
"",
" type Collection⟦T⟧ = Object & interface {",
" // Note that Collection does not include :: or hash, so collections",
" // cannot be used as keys in dictionaries (although Sequences can).",
" // In general, a collection may be mutable; Lists are, but Sequences are not.",
"",
" iterator → Iterator⟦T⟧",
" // the iterator on which I am based",
" isEmpty → Boolean",
" // true if I have no elements",
" size → Number",
" // my size (the number of elements that I contain);",
" // may raise SizeUnknown.",
" sizeIfUnknown(action: Function0⟦Number⟧)",
" // my size; if not known, then the result of applying action",
" == (other) → Boolean",
" // other and self have the same size, and contain the same elements.",
" ≠ (other) → Boolean",
" // other and self do not contain the same elements.",
" first → T",
" // my first element; raises BoundsError if I have none.",
" do (body: Procedure1⟦T⟧) → Done",
" // an internal iterator; applies body to each of my elements",
" do (body:Procedure1⟦T⟧) separatedBy(separator:Procedure0) → Done",
" // an internal iterator; applies body to each of my elements, and applies separator in between",
" ++ (other: Collection⟦T⟧) → Collection⟦T⟧",
" // returns a new Collection over the concatenation of self and other",
" fold (binaryFunction:Function2⟦T, T, T⟧) startingWith(initial:T) → T",
" // the left-associative fold of binaryFunction over self, starting with initial",
" map⟦U⟧ (function:Function1⟦T, U⟧) → Collection⟦U⟧",
" // returns a new collection that yields my elements mapped by function",
" filter (condition:Predicate1⟦T⟧) → Collection⟦T⟧",
" // returns a new collection that yields those of my elements for which condition holds",
" contains (elem:T) → Boolean",
" // returns true if elem is one of my elements",
" anySatisfy (condition:Predicate1⟦T⟧) → Boolean",
" // returns true if I contain an element e such that condition.apply(e) holds",
" allSatisfy (condition:Predicate1⟦T⟧) → Boolean",
" // returns true all of my elements e are such that condition.apply(e) holds",
" >> (target: Sink⟦T⟧) → Collection⟦T⟧",
" // returns target << self; used for writing pipelines",
" << (source: Collection⟦T⟧) → Collection⟦T⟧",
" // returns self ++ source; used for writing pipelines",
" }",
"",
" type Number = EqualityObject & interface {",
" @ (other: Number) → Point",
" // answers a point with self as the x-coordinate, and other as the y-coordinate",
"",
" ^ (n: Object) → Number",
" // answers self raised to the power n, if n is a Number.",
" // Otherwise, answers n.reversePowerNumber(self)",
"",
" sqrt → Number",
" // answers the square root of self",
"",
" + (n: Object) → Number",
" // sum of self and n, if n is a Number.",
" // Otherwise, answers n.reversePlusNumber(self)",
"",
" - (n: Object) → Number",
" // difference of self and n, if n is a Number.",
" // Otherwise, answers n.reverseMinusNumber(self)",
"",
" * (n: Object) → Number",
" // product of self and n, if n is a Number.",
" // Otherwise, answers n.reverseTimesNumber(self)",
"",
" / (n: Object) → Number",
" // quotient of self divided by n (in general, a fraction), if n is a Number.",
" // Otherwise, answers n.reverseDivideNumber(self)",
"",
" % (n: Object) → Number",
" // if n is a Number, answers the remainder r after integer division of",
" // self by n, where 0 ≤ r < self; see also ÷.",
" // If n is not a Number, answers n.reverseRemainderNumber(self)",
"",
" ÷ (n: Object) → Number",
" // quotient q of self after integer division by n, if n is a Number:",
" // self = (n * q) + remainder, where remainder = (self % other)",
" // If n is not a Number, answers n.reverseQuotientNumber(self)",
"",
" .. (last: Number) → Sequence⟦Number⟧",
" // the Sequence of numbers from self to last, so 2..4 contains 2, 3, and 4",
"",
" downTo(last:Number) → Sequence⟦Number⟧",
" // the Sequence of numbers from self down to last, so 2.downTo 0 contains 2, 1 and 0.",
"",
" < (other: Number) → Boolean",
" // true iff self is less than other",
"",
" <= (other: Number) → Boolean",
" // true iff self is less than or equal to other",
"",
" > (other: Number) → Boolean",
" // true iff self is greater than other",
"",
" >= (other: Number) → Boolean",
" // true iff self is greater than or equal to other",
"",
" prefix - → Number",
" // negation of self",
"",
" compare (other:Number) → Number",
" // a three-way comparison: -1 if (self < other), 0 if (self == other), and +1 if (self > other).",
" // This is useful when writing a comparison function for sortBy",
"",
" inBase (base:Number) → String",
" // a string representing self as a base number (e.g., 5.inBase 2 = \"101\")",
"",
" asString → String",
" // returns a string representing self rounded to six decimal places",
"",
" asDebugString → String",
" // returns a string representing self with all available precision",
"",
" asStringDecimals(d) → String",
" // returns a string representing self with exactly d decimal digits",
"",
" isInteger → Boolean",
" // true if number is an integer, i.e., a whole number with no fractional part",
"",
" truncated → Number",
" // number obtained by throwing away self's fractional part",
"",
" rounded → Number",
" // whole number closest to self",
"",
" floor → Number",
" // largest whole number less than or equal to self",
"",
" ceiling → Number",
" // smallest whole number greater than or equal to self",
"",
" abs → Number",
" // the absolute value of self",
"",
" sgn → Number",
" // the signum function: 0 when self == 0, -1 when self < 0, and +1 when self > 0",
"",
" isNaN → Boolean",
" // true if this Number is not a number, i.e., if it is NaN. For example, 0/0 returns NaN",
"",
" isEven → Boolean",
" // true if this number is even",
"",
" isOdd → Boolean",
" // true if this number is odd",
"",
" sin → Number",
" // trigonometric sine (self in radians)",
"",
" cos → Number",
" // cosine (self in radians)",
"",
" tan → Number",
" // tangent (self in radians)",
"",
" asin → Number",
" // arcsine of self (result in radians)",
"",
" acos → Number",
" // arccosine of self (result in radians)",
"",
" atan → Number",
" // arctangent of self (result in radians)",
"",
" lg → Number",
" // log base 2 of self",
"",
" ln → Number",
" // the natural log of self",
"",
" exp → Number",
" // e raised to the power of self",
"",
" log10 → Number",
" // log base 10 of self",
"",
" prefix > → Pattern",
" // a pattern that matches all numbers > self",
"",
" prefix ≥ → Pattern",
" // a pattern that matches all numbers ≥ self",
"",
" prefix < → Pattern",
" // a pattern that matches all numbers < self",
"",
" prefix ≤ → Pattern",
" // a pattern that matches all numbers ≤ self",
"",
" prefix == → Pattern",
" // a pattern that matches all numbers == self",
" }",
"",
" type Point = EqualityObject & interface {",
"",
" x → Number",
" // the x-coordinates of self",
"",
" y → Number",
" // the y-coordinate of self",
"",
" == (other:outer.Object) → Boolean",
" // true if other is a Point with the same x and y coordinates as self.",
"",
" + (other:Point|Number) → Point",
" // if other is a Point, returns the Point that is the vector sum of self",
" // and other, i.e. (self.x+other.x) @ (self.y+other.y). If other is a Number,",
" // returns the point (self.x+other) @ (self.y+other)",
"",
" - (other:Point|Number) → Point",
" // if other is a Point, returns the Point that is the vector difference of",
" // self and other, i.e. (self.x-other.x) @ (self.y-other.y). If other is a",
" // Number, returns the point (self.x-other) @ (self.y-other)",
"",
" prefix - → Point",
" // the negation of self",
"",
" * (factor:Number) → Point",
" // this point scaled by factor, i.e. (self.x*factor) @ (self.y*factor)",
"",
" / (factor:Number) → Point",
" // this point scaled by 1/factor, i.e. (self.x/factor) @ (self.y/factor)",
"",
" length → Number",
" // distance from self to the origin",
"",
" distanceTo(other:Point) → Number",
" // distance from self to other",
"",
" dot (other:Point) → Number",
" ⋅ (other:Point) → Number",
" // dot product of self and other: (self.x * other.x) + (self.y + other.y)",
"",
" norm → Point",
" // the unit vector (vecor of length 1) in same direction as self",
"",
" reverseTimesNumber(n:Number) → Point // for double-dispatch; answers (n * x)@(n * y)",
" reversePlusNumber(n:Number) → Point // for double-dispatch; answers (n + x)@(n + y)",
" reverseDivideNumber(n:Number) → Point // for double-dispatch; answers (n / x)@(n / y)",
" reverseMinusNumber(n:Number) → Point // for double-dispatch; answers (n - x)@(n - y)",
" }",
"",
" type Sink⟦T⟧ = interface {",
" << (source:Collection⟦T⟧) → Collection⟦T⟧",
" }",
"",
" type CollectionFactory⟦T⟧ = Object & interface {",
" empty → Collection⟦T⟧ // an empty collection",
" with(element:T) → Collection⟦T⟧ // a collection containing a single element",
" withAll(source:Collection⟦T⟧) → Collection⟦T⟧ // a collection containing the elements of source",
" << (source:Collection⟦T⟧) → Collection⟦T⟧ // a collection containing the elements of source",
" }",
"",
" type Iterator⟦T⟧ = interface {",
" hasNext → Boolean",
" next → T",
" }",
"",
" type Enumerable⟦T⟧ = Collection⟦T⟧ & interface {",
" values → Collection⟦T⟧",
" keysAndValuesDo(action:Function2⟦Number,T,Object⟧) → Done",
" sortedBy(comparison:Function2⟦T,T,Number⟧) → SelfType",
" sorted → SelfType",
" }",
"",
" type Sequenceable⟦T⟧ = Enumerable⟦T⟧ & interface {",
" size → Number",
" at(n:Number) → T",
" at⟦W⟧(n:Number) ifAbsent(action:Function0⟦W⟧) → T | W",
" indices → Sequence⟦Number⟧",
" keys → Sequence⟦Number⟧",
" second → T",
" third → T",
" fourth → T",
" fifth → T",
" last → T",
" indexOf⟦W⟧(elem:T) ifAbsent(action:Function0⟦W⟧) → Number | W",
" indexOf(elem:T) → Number",
" reversed → Sequence⟦T⟧",
" }",
"",
" type Sequence⟦T⟧ = EqualityObject & Sequenceable⟦T⟧",
"",
" type SelfType = Unknown // becuase Self is not yet in the language",
"}" ];
}
function gracecode_basicTypesBundle() {
importedModules["basicTypesBundle"] = this;
const var_$module = this;
this.definitionModule = "basicTypesBundle";
this.definitionLine = 1;
setLineNumber(1); // compilenode dialect
// Dialect "none"
const var_$dialect = new GraceModule("none");
this.outer = var_$dialect;
setLineNumber(2); // compilenode import
// Import of "intrinsic" as intrinsic
if (typeof gracecode_intrinsic == "undefined")
throw new GraceExceptionPacket(EnvironmentExceptionObject,
new GraceString("could not find module intrinsic"));
var var_intrinsic = do_import("intrinsic", gracecode_intrinsic);
var func0 = function(argcv) { // accessor method intrinsic, line 2
const numArgs = arguments.length - 1;
if (numArgs > 0) raiseTypeArgError("intrinsic", 0, numArgs - 0);
return var_intrinsic;
}; // end of method intrinsic
this.methods["intrinsic"] = func0;
func0.methodName = "intrinsic";
func0.paramCounts = [0];
func0.paramNames = [];
func0.definitionLine = 2;
func0.definitionModule = "basicTypesBundle";
func0.debug = "import";
func0.confidential = true;
this.closureKeys = this.closureKeys || [];
this.closureKeys.push("outer_basicTypesBundle_1");
this.outer_basicTypesBundle_1 = var_$dialect;
var func1 = function(argcv) { // method open, line 4
var returnTarget = invocationCount;
invocationCount++;
const numArgs = arguments.length - 1;
if ((numArgs > 0) && (numArgs !== 0)) {
raiseTypeArgError("open", 0, numArgs - 0);
}
var ouc = emptyGraceObject("open", "basicTypesBundle", 4);
var ouc_init = this.methods["open$build(3)"].call(this, null, ouc, [], []);
ouc_init.call(ouc);
return ouc;
}; // end of method open
this.methods["open"] = func1;
func1.methodName = "open";
func1.paramCounts = [0];
func1.paramNames = [];
func1.definitionLine = 4;
func1.definitionModule = "basicTypesBundle";
var func2 = function(argcv, inheritingObject, aliases, exclusions) { // method open$build(_,_,_), line 4
var r