Skip to content

Instantly share code, notes, and snippets.

@inariksit
Created June 4, 2020 17:53
Show Gist options
  • Save inariksit/88281c9698fd45a5f2bd00aaf14fa183 to your computer and use it in GitHub Desktop.
Save inariksit/88281c9698fd45a5f2bd00aaf14fa183 to your computer and use it in GitHub Desktop.
GF grammar to see new error msgs to common errors
abstract Errors = {
cat S ; A ;
fun
thisWorks : S ;
patternMatchingRuntime : A -> S ;
unsupportedTokenGluing : A -> S ;
nonexhaustivePattern : A ;
tooFewArgs, tooManyArgs : A ;
}
concrete ErrorsCnc of Errors = open Prelude in {
lincat S, A = SS ;
lin
thisWorks = ss "no errors here" ;
-- nonexhaustivePattern = mkSS "foox" ;
-- unsupportedTokenGluing a = ss (a.s + "illegal") ;
-- tooManyArgs = mkSS2 "too" "many" "args" ;
-- tooFewArgs = mkSS2 "toofew" ;
-- patternMatchingRuntime a = ss (case a.s of {"foo" => "bar"}) ;
oper
mkSS : Str -> SS = \str ->
case str of {
x + "foo" => ss (x + "bar")
} ;
mkSS2 : Str -> Str -> SS = \str,dummy -> ss str ;
-- mkSSTooManyInTypeSignature : Str -> Str -> SS = \x -> ss x ;
-- mkSSTooFewInTypeSignature : Str -> SS = \x,y -> ss x ;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment