Skip to content
This repository
Browse code

simplify pattern match

  • Loading branch information...
commit 9969d58757a33266212b6bf4946bad0641ad54a6 1 parent e6bbbd4
Mike Ledger mikeplus64 authored

Showing 1 changed file with 3 additions and 10 deletions. Show diff stats Hide diff stats

  1. +3 10 src/Control/Lens/TH.hs
13 src/Control/Lens/TH.hs
@@ -832,13 +832,6 @@ hasClassAndInstance :: FieldRules -> Name -> Q [Dec]
832 832 hasClassAndInstance cfg src = do
833 833 c <- newName "c"
834 834 e <- newName "e"
835   - (vs, rs) <- do
836   - s <- reify src
837   - case s of
838   - TyConI (DataD _ _ vs' [Rec _ rs''] _) -> case rs'' of
839   - [Rec _ rs'] -> return (vs', rs')
840   - _ -> error "Can't makeFields for sum types."
841   - _ -> error "Invalid source type."
842 835 TyConI (DataD _ _ vs [RecC _ rs] _) <- reify src
843 836 fmap concat . forM (mkFields cfg rs) $ \(Field field _ fullLensName className lensName) -> do
844 837 classHas <- classD
@@ -850,9 +843,9 @@ hasClassAndInstance cfg src = do
850 843 fieldType <- do
851 844 VarI _ t _ _ <- reify field
852 845 case t of
853   - AppT _ fieldType -> return fieldType
854   - ForallT tvs' [] (AppT _ fieldType) -> return fieldType
855   - _ -> error "Cannot get fieldType"
  846 + AppT _ fieldType -> return fieldType
  847 + ForallT _ [] (AppT _ fieldType) -> return fieldType
  848 + _ -> error "Cannot get fieldType"
856 849 instanceHas <- instanceD
857 850 (return [])
858 851 (conT className `appsT` [conT src `appsT` map (varT.view name) vs, return fieldType])

0 comments on commit 9969d58

Please sign in to comment.
Something went wrong with that request. Please try again.