Semigroup Result instance?

Aberta
#96 2 comentários 2 reações 0 responsáveis Ver no GitHub

Ninguém assumiu esta issue ainda.

  • #101 de @np — fechado sem integrar

Avaliação

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

Direção de pesquisa

Read the proposed Semigroup and Monoid instances in the issue body and the linked pull request #101 for prior discussion. Decide whether combining Result values this way fits the library’s API and supports the shown QuickCheck use case; the issue does not name implementation files or tests, so locate the existing Result definitions and instances before judging completion.

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

Descrição

type: enhancement

How would we feel about the following?

instance semigroupResult :: Semigroup Result where
  Success <> r = r
  Failed str <> _ = Failed str

instance monoidResult :: Monoid Result where
  mempty = Success

This is a use case I have in mind

  log "fromRotationMatrix avoids instability issues when the quaternion has one very small component"
  quickCheck \(VerySmallNum e) a b c ->
    let
      testWith p' =
        let
          p = Rotation.fromQuaternion p'
          q = unsafePartial (Rotation.fromRotationMatrix (Rotation.toRotationMatrix p))
        in
          rApproxEq p q
          <?> show { p, q }
    in
      fold
       [ testWith (Quaternion e a b c)
       , testWith (Quaternion a e b c)
       , testWith (Quaternion a b e c)
       , testWith (Quaternion a b c e)
       ]

Of course I could rewrite this test to call quickCheck four times instead, but I think the instance makes sense, and I think it would be nice to allow writing tests this way. Additionally, if generating random values for a given type is expensive, being able to combine Result values in this way could let you cut down the number of random values you need to generate, since you don't need to call quickCheck as many times.

Linguagem predominante
PureScript
Estrelas
108
Forks
42
Merge médio
2d 23h
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.

Mais de purescript/purescript-quickcheck

Todas as issues de purescript/purescript-quickcheck

Issues semelhantes

Mais issues de Testing & QA

Receba novas issues na sua caixa de entrada

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