{-# OPTIONS_GHC -fno-warn-orphans #-}

Module      : Text.ParseErrorEq
Description : Adds an Eq instance for Parsec's ParseError type if needed
Copyright   : (c) Stack Builders Inc., 2015
License     : GPL-3
Maintainer  : justin@stackbuilders.com
Stability   : experimental
Portability : POSIX

This module adds an Eq instance for Parsec's ParseError type if it's
needed. Import by using (since this module only provides instances):

> import Text.ParseErrorEq ()

For reference, Parsec 3.1.9 adds the Eq instance, in the commit here:

module Text.ParseErrorEq where

#if MIN_VERSION_parsec(3,1,9)

-- ParseError Eq instance already defined in Parsec, not necessary to add.


import Text.Parsec.Error (ParseError)
import Text.ParserCombinators.Parsec.Error
  (errorPos, errorMessages, messageString)

-- This implementation of Eq for ParseError is the same as the one
--  added in Parsec in the above commit.
instance Eq ParseError where
  l == r
       = errorPos l == errorPos r && messageStrs l == messageStrs r
    where messageStrs = map messageString . errorMessages