Function symbol

  • Parse symbols like ( and ,.

      run(symbol("["))("[") // => Ok ()
    run(symbol("["))("4") // => Err ... (ExpectingSymbol "[") ...

    Note: This is good for stuff like brackets and semicolons, but it probably should not be used for binary operators like + and - because you can find yourself in weird situations. For example, is "3--4" a typo? Or is it "3 - -4"? I have had better luck with chompWhile(isSymbol) and sorting out which operator it is afterward.

    Parameters

    • str: string

    Returns Simple.Parser<Symbol>