@@ -74,6 +74,13 @@ instance Hashable ann => Hashable1 (Ann ann)
7474#ifdef MIN_VERSION_serialise
7575instance (Serialise ann , Serialise a ) => Serialise (Ann ann a )
7676#endif
77+ pattern AnnE
78+ :: forall ann (g :: * -> * )
79+ . ann
80+ -> g (Fix (Compose (Ann ann ) g ))
81+ -> Fix (Compose (Ann ann ) g )
82+ pattern AnnE ann a = Fix (Compose (Ann ann a))
83+ {-# complete AnnE #-}
7784
7885instance NFData ann => NFData1 (Ann ann )
7986
@@ -119,9 +126,6 @@ instance Serialise r => Serialise (Compose (Ann SrcSpan) NExprF r) where
119126 decode = (Compose . ) . Ann <$> decode <*> decode
120127#endif
121128
122- pattern AnnE :: forall ann (g :: * -> * ). ann
123- -> g (Fix (Compose (Ann ann) g)) -> Fix (Compose (Ann ann) g)
124- pattern AnnE ann a = Fix (Compose (Ann ann a))
125129
126130stripAnnotation :: Functor f => Fix (AnnF ann f ) -> Fix f
127131stripAnnotation = unfoldFix (annotated . getCompose . unFix)
@@ -131,33 +135,26 @@ stripAnn = annotated . getCompose
131135
132136nUnary :: Ann SrcSpan NUnaryOp -> NExprLoc -> NExprLoc
133137nUnary (Ann s1 u) e1@ (AnnE s2 _) = AnnE (s1 <> s2) $ NUnary u e1
134- nUnary _ _ = error " nUnary: unexpected"
135138{-# inline nUnary #-}
136139
137140nBinary :: Ann SrcSpan NBinaryOp -> NExprLoc -> NExprLoc -> NExprLoc
138141nBinary (Ann s1 b) e1@ (AnnE s2 _) e2@ (AnnE s3 _) =
139142 AnnE (s1 <> s2 <> s3) $ NBinary b e1 e2
140- nBinary _ _ _ = error " nBinary: unexpected"
141143
142144nSelectLoc
143145 :: NExprLoc -> Ann SrcSpan (NAttrPath NExprLoc ) -> Maybe NExprLoc -> NExprLoc
144146nSelectLoc e1@ (AnnE s1 _) (Ann s2 ats) d = case d of
145147 Nothing -> AnnE (s1 <> s2) $ NSelect e1 ats Nothing
146148 Just e2@ (AnnE s3 _) -> AnnE (s1 <> s2 <> s3) $ NSelect e1 ats $ pure e2
147- _ -> error " nSelectLoc: unexpected"
148- nSelectLoc _ _ _ = error " nSelectLoc: unexpected"
149149
150150nHasAttr :: NExprLoc -> Ann SrcSpan (NAttrPath NExprLoc ) -> NExprLoc
151151nHasAttr e1@ (AnnE s1 _) (Ann s2 ats) = AnnE (s1 <> s2) $ NHasAttr e1 ats
152- nHasAttr _ _ = error " nHasAttr: unexpected"
153152
154153nApp :: NExprLoc -> NExprLoc -> NExprLoc
155154nApp e1@ (AnnE s1 _) e2@ (AnnE s2 _) = AnnE (s1 <> s2) $ NBinary NApp e1 e2
156- nApp _ _ = error " nApp: unexpected"
157155
158156nAbs :: Ann SrcSpan (Params NExprLoc ) -> NExprLoc -> NExprLoc
159157nAbs (Ann s1 ps) e1@ (AnnE s2 _) = AnnE (s1 <> s2) $ NAbs ps e1
160- nAbs _ _ = error " nAbs: unexpected"
161158
162159nStr :: Ann SrcSpan (NString NExprLoc ) -> NExprLoc
163160nStr (Ann s1 s) = AnnE s1 $ NStr s
0 commit comments