gm + gmPrep wiring

This commit is contained in:
crumbtoo
2023-12-11 18:05:17 -07:00
parent b31c50dd72
commit b371e84d80
3 changed files with 30 additions and 9 deletions

View File

@@ -25,6 +25,7 @@ module Core.Syntax
, Alter'
, Binding'
, HasRHS(_rhs)
, HasLHS(_lhs)
)
where
----------------------------------------------------------------------------------
@@ -132,3 +133,16 @@ instance HasRHS (Binding b) b where
(\ (_ := e) -> e)
(\ (k := _) e' -> k := e')
class HasLHS s a | s -> a where
_lhs :: Lens' s a
instance HasLHS (Alter b) (AltCon, [b]) where
_lhs = lens
(\ (Alter a bs _) -> (a,bs))
(\ (Alter _ _ e) (a',bs') -> Alter a' bs' e)
instance HasLHS (ScDef b) (b, [b]) where
_lhs = lens
(\ (ScDef n as _) -> (n,as))
(\ (ScDef _ _ e) (n',as') -> (ScDef n' as' e))