1- {-# LANGUAGE DefaultSignatures, DeriveGeneric, DerivingVia, FlexibleContexts, FlexibleInstances, RecordWildCards, StandaloneDeriving, TypeOperators, UndecidableInstances #-}
1+ {-# LANGUAGE DefaultSignatures, DeriveGeneric, FlexibleContexts, FlexibleInstances, RecordWildCards, StandaloneDeriving, TypeOperators #-}
22module Language.Python.Core
33( compile
44) where
@@ -18,7 +18,7 @@ class Compile t where
1818defaultCompile :: (MonadFail m , Show t ) => t -> m Core
1919defaultCompile 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
2323instance Compile Py. AssertStatement
2424instance Compile Py. Await
@@ -28,15 +28,15 @@ instance Compile Py.BreakStatement
2828instance Compile Py. ClassDefinition
2929instance Compile Py. ComparisonOperator
3030
31- deriving via CompileSum Py. CompoundStatement instance Compile Py. CompoundStatement
31+ instance Compile Py. CompoundStatement where compile = compileSum
3232
3333instance Compile Py. ConditionalExpression
3434instance Compile Py. ContinueStatement
3535instance Compile Py. DecoratedDefinition
3636instance Compile Py. DeleteStatement
3737instance Compile Py. ExecStatement
3838
39- deriving via CompileSum Py. Expression instance Compile Py. Expression
39+ instance Compile Py. Expression where compile = compileSum
4040
4141instance Compile Py. ExpressionStatement
4242instance Compile Py. ForStatement
@@ -68,13 +68,16 @@ instance Compile Py.PrintStatement
6868instance Compile Py. ReturnStatement
6969instance Compile Py. RaiseStatement
7070
71- deriving via CompileSum Py. SimpleStatement instance Compile Py. SimpleStatement
71+ instance Compile Py. SimpleStatement where compile = compileSum
7272
7373instance Compile Py. TryStatement
7474instance Compile Py. WhileStatement
7575instance Compile Py. WithStatement
7676
7777
78+ compileSum :: (Generic t , GCompileSum (Rep t ), MonadFail m ) => t -> m Core
79+ compileSum = gcompileSum . from
80+
7881class 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
9396deriving instance Generic Py. CompoundStatement
9497deriving instance Generic Py. Expression
9598deriving 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