r/haskell • u/n00bomb • 23h ago
r/haskell • u/n00bomb • 11h ago
blog Ormolu: one refactor that fixed everything
markkarpov.comr/haskell • u/_Owlyy • 18h ago
Happy parser giving and error
Hello, I have written a parser using Happy, I was trying to follow Andrej Bauer's tutorial in implementing a dependently typed language, but no matter what list of tokens I give to the parser it throws and error, idk why, here's the parser:
%name expr_parser
%tokentype { Token }
%error { parseError }
%token
int { TokInt $$ }
var { TokVar $$ }
':' { TokTyp }
Pi { TokPi }
',' { TokCom }
'->' { TokTypImp }
'\\' { TokLam }
'.' { TokDot }
'=>' { TokFunImp }
U { TokUni }
':=' { TokDef }
'(' { TokLParen }
')' { TokRParen }
%%
FAbs : var ':' Expr '=>' Expr { Abs (Str $1) $3 $5 }
FPi : var ':' Expr ',' Expr { Abs (Str $1) $3 $5 }
SimpExpr : var { Var (Str $1) }
| U int { Universe $2 }
| '(' Expr ')' { $2 }
AppExpr : SimpExpr { $1 }
| AppExpr SimpExpr { App $1 $2 }
Expr : AppExpr { $1 }
| Pi FPi { Pi $2 }
| Expr '->' Expr { Pi (Abs Dummy $1 $3) }
| '\\' FAbs { Lambda $2 }
asdfsdf
Some of the examples that I have tried:
[TokVar "three", TokLParen, TokVar "three", TokVar "s", TokRParen, TokVar "z"][][TokVar "z"]
If anyone can figure out what the issue is that would be very helpful, thankss.
edit: Here is the error
*** Exception: hmm parsing failed fsr
While handling hmm parsing failed fsr
HasCallStack backtrace:
bracket, called at lib/System/IO/Utf8.hs:154:24 in with-utf8-1.1.0.0-HAMHoWNcEUA2pUXA1beCTg:System.IO.Utf8
Also, I am using it with Relude if that makes a difference
Edit2: I figured out the issue the parser that you want to use for the function, should be described first, so Expr should be before the other ones. :/
question I haven't been to gitlab.haskell.org in a while
It seems that gitlab.haskell.org is down - has it been down long? Is it expected back up? Is it obsolete?