1
1
mirror of https://github.com/github/semantic.git synced 2024-12-22 22:31:36 +03:00

Define an Eq1 instance for BindingF.

This commit is contained in:
Rob Rix 2017-09-10 21:47:43 -04:00
parent ad83303071
commit bc7ed4420e

View File

@ -2,6 +2,7 @@
module Data.Functor.Binding where module Data.Functor.Binding where
import Data.Aeson (KeyValue(..), ToJSON) import Data.Aeson (KeyValue(..), ToJSON)
import Data.Functor.Classes
import Data.JSON.Fields import Data.JSON.Fields
import Data.Text.Prettyprint.Doc import Data.Text.Prettyprint.Doc
@ -25,6 +26,12 @@ envLookup :: Metavar -> Env a -> Maybe a
envLookup var = lookup var . unEnv envLookup var = lookup var . unEnv
instance Eq1 f => Eq1 (BindingF f) where
liftEq eq (Let v1 b1) (Let v2 b2) = liftEq (liftEq eq) v1 v2 && liftEq eq b1 b2
liftEq _ (VarF v1) (VarF v2) = v1 == v2
liftEq _ _ _ = False
instance Pretty Metavar where instance Pretty Metavar where
pretty (Metavar v) = pretty v pretty (Metavar v) = pretty v