Skip to content
This repository was archived by the owner on Apr 1, 2025. It is now read-only.

Commit 4ed026b

Browse files
committed
Define an Eq1 instance for Python.
1 parent 0297116 commit 4ed026b

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

  • semantic-analysis/src/Analysis/Syntax

semantic-analysis/src/Analysis/Syntax/Python.hs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import Analysis.VM
3535
import Control.Effect.Labelled
3636
import Control.Effect.Reader
3737
import Data.Function (fix)
38+
import Data.Functor.Classes (Eq1 (..))
3839
import Data.List.NonEmpty (NonEmpty)
3940
import Data.Text (Text)
4041
import Source.Span (Span)
@@ -114,6 +115,25 @@ pattern Locate s t = Locate' s T.:$: T.Cons t T.Nil
114115
{-# COMPLETE Noop, Iff, Bool, String, Throw, Let, (:>>), Import, Function, Call, Locate #-}
115116

116117

118+
instance Eq1 Python where
119+
liftEq _ a b = case (a, b) of
120+
(Noop', Noop') -> True
121+
(Iff', Iff') -> True
122+
(Bool' b1, Bool' b2) -> b1 == b2
123+
(String' s1, String' s2) -> s1 == s2
124+
(Throw', Throw') -> True
125+
(Let' n1, Let' n2) -> n1 == n2
126+
((:>>>), (:>>>)) -> True
127+
(Import' i1, Import' i2) -> i1 == i2
128+
(Function' n1 as1, Function' n2 as2) -> n1 == n2 && as1 == as2
129+
(Call', Call') -> True
130+
(ANil', ANil') -> True
131+
(ACons', ACons') -> True
132+
(Locate' s1, Locate' s2) -> s1 == s2
133+
_ -> False
134+
135+
136+
117137
-- Abstract interpretation
118138

119139
eval0 :: (Has (Env addr) sig m, HasLabelled Store (Store addr val) sig m, Has (Dom val) sig m, Has (Reader Reference) sig m, Has S.Statement sig m) => Term -> m val

0 commit comments

Comments
 (0)