Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

One more point. Writing something like the MiniLatex parser would be somewhere between impossible altogether and nightmarish without an expressive type system. Below is the definition of the type of the abstract syntax tree (AST) for MiniLatex. Just eleven lines of code. Yes, I know. No typeclasses in Elm. But Elm's type system is surprisingly expressive, and with it one can do some rather sophisticated work. I've been very happy with it.

    type LatexExpression
        = LXString String
        | Comment String
        | Item LatexExpression
        | InlineMath String
        | DisplayMath String
        | SMacro String (List LatexExpression) (List LatexExpression) LatexExpression 
        | Macro String (List LatexExpression) (List LatexExpression) 
        | Environment String (List LatexExpression) LatexExpression 
        | LatexList (List LatexExpression)
        | LXError (List DeadEnd)


Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: