feat(library/init/lean/parser/parsec): mark whitespace and num with [noinline]

We want them to be specialized for a given monad stack, but not
inlined. If we inline them, then every occurrence of `whitespace` and
`num` will specialize the nested `take_while?` application.
This is bad since we don't cache them.
This commit is contained in:
Leonardo de Moura 2018-10-18 16:33:10 -07:00
parent 677864dee5
commit 0f7745a3e0

View file

@ -438,7 +438,7 @@ lift $ λ it, take_while_aux' p it.remaining ff it
satisfy p *> take_while' p
/-- Consume zero or more whitespaces. -/
def whitespace : m unit :=
@[noinline] def whitespace : m unit :=
take_while' char.is_whitespace
/-- Shorthand for `p <* whitespace` -/
@ -446,7 +446,7 @@ take_while' char.is_whitespace
p <* whitespace
/-- Parse a numeral in decimal. -/
def num : m nat :=
@[noinline] def num : m nat :=
string.to_nat <$> (take_while1 char.is_digit)
/-- Succeed only if there are at least `n` characters left. -/