Constant not found: overload in GF

89 Views Asked by At

I was trying to make an overload of function that I have created on GF, but after using the overload function I keep getting this error message. enter image description here

Am I using this function of GF incorrectly or is there is any new update to this functionality.

Here is what I was trying to do

Sentence = sentence(mkN(“random”));

oper

sentence:overload {

sentence:N-> Utt =

\noun->

mkUtt(mkNP(noun));

sentence:V-> Utt =

\ verb->

mkutt(mkImp(mkV2(verb)));

};


Thank you~

2

There are 2 best solutions below

0
On BEST ANSWER

Weird unicode characters

There are a lot of things wrong in this sample. First of all, it seems like you have written it in a word processor instead of a text editor, because the characters are not what they are supposed to be. For instance, : is the real colon, and your code snippet has , which is a different Unicode codepoint. Look at them side by side:

:: -- first the wrong one, followed by the correct one

:: -- The wrong colon includes more space
:: -- the right colon is thicker and less space

The solution to this problem is to program in a text editor (like Atom or Sublime) or a programming IDE (like VS code), not in a word processor. Many editors don't have a syntax highlighting for GF, but you can see in this video how to use Haskell mode instead.

Actual problem

Now let's suppose we fixed the characters, then we have this.

sentence : overload {

  sentence : N -> Utt =
    \noun -> mkUtt (mkNP noun) ;

  sentence : V -> Utt =
    \verb -> mkUtt something_NP ; -- the original had an unrelated bug
  } ;

Now we get the error you describe. The solution is to change the first : to a =, like this:

sentence = overload { -- = used to be :

{-  sentence : N -> Utt =         -- the rest unchanged
    \noun -> mkUtt (mkNP noun) ;

  sentence : V -> Utt =
    \verb -> mkUtt something_NP ; -- the original had an unrelated bug
  } ; -}

Working version of the whole

As Paula said, your example is just fragments. Here's a minimal fully working version.

abstract Sentences = {

  cat
    S ;
  fun
    Sentence : S ;
}

And here's a concrete, with all the weird Unicode characters swapped out for actual characters. I also fixed the mkImp instance for V2: if you see here in the synopsis, there's no mkImp instance for a single V2, it's either V or V2 and NP.

concrete SentencesEng of Sentences = open SyntaxEng, ParadigmsEng in {

  lincat
    S = Utt ;
  lin
    Sentence = sentence (mkN "random") ;

oper

sentence = overload {

  sentence : N -> Utt =
    \noun -> mkUtt (mkNP noun) ;

  sentence : V -> Utt =
    \verb -> mkUtt (mkImp (mkV2 verb) something_NP) ;
  } ;

}
0
On

It looks like your code is a snippet, so there may be a few things preventing your grammar from compiling.

To start, if you check the documentation, you can see that there are two forms for overloading operations.

You are using the syntax to give the types to define the operations. Instead, you should use this existing code with the syntax for defining the operations.

oper sentence = overload {...} ;

The syntax that you are using should be used to define your types before you make the overload oper.