-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Internal error with Ints
#91
Comments
Hi @WolframKahl , It seems that the reference manual just needs updating The actual problem is the internal error in Compute.ConcreteNew. The comments in Predef.gf say "Applying them [the opers] to run-time variables leads to compiler errors that are often only detected at the code generation time." So calling However, abstract Numbers = {
cat
Nat ;
fun
Zero : Nat ;
Succ : Nat -> Nat ;
} And concrete: concrete NumbersCnc of Numbers = open Predef, Prelude in {
lincat
Nat = {n : Ints 10} ;
lin
Zero = {n = 0} ;
Succ x = {n = myPlus1 ! x.n} ;
oper
myPlus1 : Ints 10 => Ints 10 = table {
0 => 1 ;
1 => 2 ;
2 => 3 ;
3 => 4 ;
4 => 5 ;
5 => 6 ;
6 => 7 ;
7 => 8 ;
8 => 9 ;
_ => 10
} ;
} Let's test this in the GF shell:
Obviously, this doesn't scale up, and is very tedious to write. Just demonstrating that it is possible to pattern match Maybe @aarneranta or @krangelov can share more insight here, is it possible to do something more interesting on |
My first point was that as user, I don't expect to see internal errors, but assume that the developers would like to be informed when I do see one, since with an internal error, the system is blaming its developers for a situation it cannot handle. 😉 My second point was that the fact that the reference manual says
leads me to expect that
is available, and since 16 is a compile-time constant, I am optimistically hoping that the corresponding table I did find the
But I am guessing that even spelling out all 289 cases would not make a performance difference in the compiled result? |
Fair enough. I'll amend my pending PR #93 to add a better error message for this too.
Yeah, I would expect that too. Clearly
I don't know the answer to this either. |
In the reference manual I find
and
I therefore would expect being able to apply
lessInt
toInts
values, but withand
, gf-3.10 produces:
My original attempt was to use
lessInt
for a better implementation oflessPrec
ina custom copy of
prelude/Formal.gf
with more than five precedence levels:This produces:
In this context, I also found it surprising that
prelude/Predef.gf
actually haswith
Int
, instead of withInteger
as the reference manual appears to suggest.The text was updated successfully, but these errors were encountered: