HAPPY(1)
π HAPPY(1) β the Happy Parser Generator, explained by your resident Unix bestie π
Okay so happyβ¦ it's the parser generator for Haskell, and it lives in the manual section 1 of the Happy Parser Generator pages. Buckle up bestie, we're getting into grammars β¨
π¦ SYNOPSIS
happy [OPTION]... file [OPTION]...
πΈ DESCRIPTION
This page is the quick-and-dirty little briefing on the happy command, nothing more π
Real talk: this man page was written for the Debian GNU/Linux distribution because the original program literally doesn't ship a manual page of its own π Instead it has documentation in a whole bunch of other formats β DVI, Info and HTML included β so peep below for where to find those.
So what is Happy? It's a parser generator system for Haskell. And HAPPY? Adorable fact: it's a dyslexic acronym for A Yacc-like Haskell Parser generator π
There are two types of grammar files, file.y and file.ly β the .ly ones observe the reverse comment bird track convention, meaning every single code line has to begin with >. The examples that ship with Happy are all of the .ly form, iykyk π¦
β οΈ Caveat, and listen up: when you're usinghbc(Chalmers Haskell), the command argument structure is slightly different. Why? Because the hbc run time system grabs some flags for itself (things like setting the heap size, etc). You can dodge the whole problem by adding a single dash (-) to your command line. So with an hbc-generated version of Happy, the argument structure is:
happy - [OPTION]... file [OPTION]...
β¨ OPTIONS β¨
These programs follow the usual GNU command line syntax, with long options starting with two dashes (--). Here's a summary of the options β for a complete description, go read the other documentation, bestie π«Ά
-h,--helpβ shows a summary of options. That's it, that's the whole vibe πββοΈ-v,--versionβ prints version information to standard output, then exits successfully. Slay and goodbye βοΈ-a,--arrayβ tells Happy to generate a parser using an array-based shift reduce parser. Team it up with-gand the arrays get encoded as strings, which means faster parsers π₯. Without-g? Standard Haskell arrays, no fancy business.-g,--ghcβ tells Happy to generate a parser that uses GHC-specific extensions to get faster code. Speed demon energy β‘-c,--coerceβ uses GHC'sunsafeCoerce#extension to generate smaller, faster parsers. But there's a catch, and it's a real one: some type safety is lost, which means a parser generated with-cmay compile just fine and then crash at run-time π So definitely compile your grammar without-cfirst to make sure it's type-correct. This option has quite a significant effect on the performance of the resulting parser β but remember, parsers generated this way can only be compiled by GHC 3.02 and above. Also: it may only be used in conjunction with-g.-d,--debugβ generates a parser that prints debugging information tostderrat run-time, including all the shifts, reductions, state transitions and token inputs the parser performs. Very "let me see your work" of it π This option may only be used in conjunction with-a.-i [FILE],--info[=FILE]β directs Happy to produce an info file with detailed information about the grammar, parser states, parser actions, and conflicts. Info files are vital during the debugging of grammars β genuinely, don't skip this one. The filename argument is optional; if you omit it, the info file gets written toFILE.info(whereFILEis the input file name with any extension removed). π-o FILE,--outfile=FILEβ specifies where the generated parser module goes. If you omit it, the parser lands inFILE.hs, whereFILEis the name of the input file with any extension removed. And ifFILEis-, the generated parser is sent to standard output π-m NAME,--magic-name=NAMEβ Happy prefixes all the symbols it uses internally with eitherhappyorHappy. Want a different string? Say, becausehappyis conflicting with one of your own functions? Specify the prefix with the-moption. Iconic customisation moment π-t DIR,--template=DIRβ instructs Happy to use this directory when looking for template files: these files contain the static code that Happy includes in every generated parser. Ngl, you shouldn't need this option if Happy is properly configured for your computer.-l,--glrβ instructs Happy to output a GLR parser instead of an LALR(1) parser. Main character energy, different parser entirely π-k,--decodeβ causes the GLR parser to generate code for decoding the parse forest to a list of semantic results (requires--ghc).-f,--filterβ causes the GLR parser to filter out nodes which aren't required for the semantic results β it's an experimental optimisation, and it requires--ghcπ
π FILES
@LIBDIR@
π§ SEE ALSO
@DOCDIR@, the Happy homepage (http://haskell.org/happy/) β go click, bestie π
β COPYRIGHT
Happy Version @VERSION@
Copyright (c) 1993-1996 Andy Gill, Simon Marlow; (c) 1997-2001 Simon Marlow
π AUTHOR
This manual page was written by Michael Weber <michaelw@debian.org>, for the Debian GNU/Linux system (but may be used by others). Respect the author, periodt π«Ά
And that's the whole page! This queen came to you from the Glasgow FP Suite, dated 2000-12-23 β yeah, she's a vintage icon and she still ate πβ¨
π¦ where this page comes from
- opensuse-leap 16.0: happy 1.20.1.1-bp160.1.13 Β· BSD-2-Clause
- opensuse-leap 16.0: happy 1.20.1.1-bp160.1.13 Β· BSD-2-Clause
- opensuse-leap 16.0: happy 1.20.1.1-bp160.1.13 Β· BSD-2-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms