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

Commit c15bbcb

Browse files
committed
Not via.
1 parent 1a6812e commit c15bbcb

File tree

1 file changed

+8
-12
lines changed
  • semantic-python/src/Language/Python

1 file changed

+8
-12
lines changed

semantic-python/src/Language/Python/Core.hs

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{-# LANGUAGE DefaultSignatures, DeriveGeneric, DerivingVia, FlexibleContexts, FlexibleInstances, RecordWildCards, StandaloneDeriving, TypeOperators, UndecidableInstances #-}
1+
{-# LANGUAGE DefaultSignatures, DeriveGeneric, FlexibleContexts, FlexibleInstances, RecordWildCards, StandaloneDeriving, TypeOperators #-}
22
module Language.Python.Core
33
( compile
44
) where
@@ -18,7 +18,7 @@ class Compile t where
1818
defaultCompile :: (MonadFail m, Show t) => t -> m Core
1919
defaultCompile t = fail $ "compilation unimplemented for " <> show t
2020

21-
deriving via CompileSum (Either l r) instance (Compile l, Compile r) => Compile (Either l r)
21+
instance (Compile l, Compile r) => Compile (Either l r) where compile = compileSum
2222

2323
instance Compile Py.AssertStatement
2424
instance Compile Py.Await
@@ -28,15 +28,15 @@ instance Compile Py.BreakStatement
2828
instance Compile Py.ClassDefinition
2929
instance Compile Py.ComparisonOperator
3030

31-
deriving via CompileSum Py.CompoundStatement instance Compile Py.CompoundStatement
31+
instance Compile Py.CompoundStatement where compile = compileSum
3232

3333
instance Compile Py.ConditionalExpression
3434
instance Compile Py.ContinueStatement
3535
instance Compile Py.DecoratedDefinition
3636
instance Compile Py.DeleteStatement
3737
instance Compile Py.ExecStatement
3838

39-
deriving via CompileSum Py.Expression instance Compile Py.Expression
39+
instance Compile Py.Expression where compile = compileSum
4040

4141
instance Compile Py.ExpressionStatement
4242
instance Compile Py.ForStatement
@@ -68,13 +68,16 @@ instance Compile Py.PrintStatement
6868
instance Compile Py.ReturnStatement
6969
instance Compile Py.RaiseStatement
7070

71-
deriving via CompileSum Py.SimpleStatement instance Compile Py.SimpleStatement
71+
instance Compile Py.SimpleStatement where compile = compileSum
7272

7373
instance Compile Py.TryStatement
7474
instance Compile Py.WhileStatement
7575
instance Compile Py.WithStatement
7676

7777

78+
compileSum :: (Generic t, GCompileSum (Rep t), MonadFail m) => t -> m Core
79+
compileSum = gcompileSum . from
80+
7881
class GCompileSum f where
7982
gcompileSum :: MonadFail m => f a -> m Core
8083

@@ -93,10 +96,3 @@ instance Compile t => GCompileSum (M1 C c (M1 S s (K1 R t))) where
9396
deriving instance Generic Py.CompoundStatement
9497
deriving instance Generic Py.Expression
9598
deriving instance Generic Py.SimpleStatement
96-
97-
98-
newtype CompileSum t = CompileSum { unCompileSum :: t }
99-
deriving (Eq, Ord, Show)
100-
101-
instance (Generic t, GCompileSum (Rep t)) => Compile (CompileSum t) where
102-
compile = gcompileSum . from . unCompileSum

0 commit comments

Comments
 (0)