Prelude.typeNameValue() for macros
This commit is contained in:
@@ -121,6 +121,8 @@ class Kiss {
|
||||
"fsMemoize" => Symbol("Prelude.fsMemoize"),
|
||||
"symbolName" => Symbol("Prelude.symbolName"),
|
||||
"symbolNameValue" => Symbol("Prelude.symbolNameValue"),
|
||||
"typeNameValue" => Symbol("Prelude.typeNameValue"),
|
||||
"typeName" => Symbol("Prelude.typeNameValue"),
|
||||
"symbol" => Symbol("Prelude.symbol"),
|
||||
"expList" => Symbol("Prelude.expList"),
|
||||
"map" => Symbol("Lambda.map"),
|
||||
|
@@ -542,7 +542,7 @@ class Prelude {
|
||||
return switch (s.def) {
|
||||
case Symbol(name): name;
|
||||
case TypedExp(_, innerExp) if (allowTyped): symbolNameValue(innerExp, false); // Meta must always precede type annotation
|
||||
case MetaExp(_, innerExp) if (allowMeta): symbolNameValue(innerExp, allowTyped, false); // TODO will more than one meta on the same expression be necessary?
|
||||
case MetaExp(_, innerExp) if (allowMeta): symbolNameValue(innerExp, allowTyped, false); // TODO will more than one meta on the same expression ever be necessary?
|
||||
default:
|
||||
var allowed = "a plain symbol";
|
||||
if (allowTyped) allowed += " or a :Typed symbol";
|
||||
@@ -551,6 +551,17 @@ class Prelude {
|
||||
};
|
||||
}
|
||||
|
||||
public static function typeNameValue(s:ReaderExp, allowMeta:Null<Bool> = false):String {
|
||||
return switch (s.def) {
|
||||
case TypedExp(type, _): type;
|
||||
case MetaExp(_, innerExp) if (allowMeta): typeNameValue(innerExp, false); // TODO will more than one meta on the same expression ever be necessary?
|
||||
default:
|
||||
var allowed = "a :Typed symbol";
|
||||
if (allowMeta) allowed += " or a &meta :Typed symbol";
|
||||
throw expected(s, allowed);
|
||||
};
|
||||
}
|
||||
|
||||
public static function uuid() {
|
||||
return Uuid.v4().toShort();
|
||||
}
|
||||
|
Reference in New Issue
Block a user