OneOf?

Aberta
#68 4 comentários 0 reações 0 responsáveis Ver no GitHub

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
2/5
Tempo estimado
1-3 horas
Facilidade para iniciantes
35/100
Tipo de issue
Funcionalidade
Clareza
Razoavelmente clara
Status de atividade
Estagnada
Domínio
backend

Direção de pesquisa

Start by reading the existing parser alternatives and error-combination operators in the library to see whether they already provide lazy, as-needed parsing. The issue includes a proposed oneOf implementation but names no files or tests; identify the relevant entry points and tests before deciding whether a new helper is needed. Done means establishing whether the helper exists or, if it does not, adding and testing the proposed behavior.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

status: needs more info

Feels like we probably already have a oneOf function that can make sure that not all branches are evaluated at once (to ensure efficient as-needed parsing), since using alt naively can lead to really really slow decoding, but I honestly don't know where it is. Is there something I'm missing that already implements this?:

oneOf :: forall f a
   . Foldable f
  => f (Foreign -> F a)
  -> Foreign
  -> F a
oneOf f js = go (fromFoldable f) js
  where
    go (read : xs) js = do
      case runExcept (read js) of
        Right pv -> pure pv
        Left e -> do
          case runExcept (go xs js) of
            Right pv' -> pure pv'
            Left e' -> throwError (e <> e')
    go Nil _ = do
      throwError $ pure (ForeignError "No more parsers to attempt in oneOf")

If not, I could PR this, but feels like it probably exists as a simple combination of some operators.

Linguagem predominante
PureScript
Estrelas
64
Forks
42
Merge médio
2d 6h
PRs com merge (30d)
1

Preparar o ambiente

  • Sem Dockerfile nem arquivo Docker Compose
  • Tem um modelo de pull request
  • Sem guia de contribuição

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Issues semelhantes

Mais issues de Backend & API Design

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.