Function succeed

  • A parser that succeeds without chomping any characters.

      run(succeed(90210    ))("mississippi") // => Ok(90210)
    run(succeed(3.141 ))("mississippi") // => Ok(3.141)
    run(succeed(true ))("mississippi") // => Ok(true)
    run(succeed(undefined))("mississippi") // => Ok(undefined)

    Seems weird on its own, but it is very useful in combination with other functions. The docs for apply and andThen have some neat examples.

    const parser = succeed("I always succeed!")
    run(parser)("doesn't matter") // => Ok("I always succeed!")

    See

    Type Parameters

    • A

    Parameters

    • v: A

    Returns Simple.Parser<A>