Skip to content

Applicative / Monad instances for Result are invalid #1

Description

@bitemyapp
{-# LANGUAGE TemplateHaskell #-}

module Main where

import           Control.Monad
import           Data.DeriveTH
import           Test.Hspec
import           Test.Hspec.QuickCheck           (prop)
import           Test.QuickCheck hiding (Result)
import           Test.QuickCheck.Checkers
import           Test.QuickCheck.Classes

import Text.Reform
import Text.Reform.Result

$(derive makeArbitrary ''FormId)
$(derive makeArbitrary ''FormRange)
$(derive makeArbitrary ''Result)

instance (Eq e, Eq a) => EqProp (Result e a) where (=-=) = eq

main :: IO ()
main = hspec $ do
  describe "Applicative/Monad instances" $ do
    it "Applicative and Monad should match behavior" $ do
      let result :: Result String (Int, String)
          result = Ok (1, "blah")
      quickBatch $ monadApplicative result
  ap:   *** Failed! Falsifiable (after 2 tests):  
Error []
Error [(FormRange -fval[0] -fval[0],"\249")]

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions