yoko 0.3.2.1 → 0.3.2.2
raw patch · 3 files changed
+19/−11 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- Data/Yoko/TH.hs +8/−5
- Data/Yoko/TH/Internal.hs +10/−5
- yoko.cabal +1/−1
Data/Yoko/TH.hs view
@@ -83,7 +83,6 @@ import qualified Control.Monad.Trans as Trans import qualified Control.Arrow as Arrow-import Control.Monad ((<=<)) import Data.Set (Set) import qualified Data.Set as Set@@ -233,7 +232,7 @@ fieldRO :: [(Int, Mapping)] -> Set Name -> Type -> Q (Type, FieldRO) fieldRO maps bg = w' where- w' = uncurry w <=< uncurry expandSyn . peelApp+ w' = uncurry w . peelApp isRec n = Set.member n bg @@ -246,9 +245,13 @@ AppT{} -> Int.thFail $ "impossible: AppT is guarded by peelApp." SigT ty _ -> uncurry w $ peelAppAcc tys ty ForallT{} -> Int.thFail $ "no support for ForallT."- ConT n- | isRec n -> if not (null recs) then Int.thFail "does not support nested recursion."- else simple True ty tys+ ConT n | isRec n -> do+ rhs <- expandSyn ty tys+ case rhs of+ Just (ty, tys) -> w ty tys+ Nothing ->+ if not (null recs) then Int.thFail "no support for nested recursion."+ else simple True ty tys _ | not (null recs) -> case lookup (length recs) maps of Nothing -> Int.thFail $ "no case in the given YokoOptions for type constructors with " ++ show (length recs) ++ " arguments."
Data/Yoko/TH/Internal.hs view
@@ -3,6 +3,7 @@ module Data.Yoko.TH.Internal where import Data.Maybe (fromMaybe)+import Control.Monad (mplus) import Language.Haskell.TH @@ -49,14 +50,18 @@ -expandSyn :: Type -> [Type] -> Q (Type, [Type])-expandSyn ty@(ConT n) tys = do+expandSyn :: Type -> [Type] -> Q (Maybe (Type, [Type]))+expandSyn (ConT n) tys = do i <- reify n case i of TyConI (TySynD _ (map tvbName -> formals) rhs) ->- uncurry expandSyn $ peelApp $ msubst (zip formals tys) rhs- _ -> return (ty, tys)-expandSyn ty tys = return (ty, tys)+ -- formals <= tys because type synonyms must be fully applied.+ -- peelAppAcc handles both formals < tys and formals == tys.+ let tytys = peelAppAcc (drop (length formals) tys) $+ msubst (zip formals tys) rhs+ in (`mplus` Just tytys) `fmap` uncurry expandSyn tytys+ _ -> return Nothing+expandSyn _ _ = return Nothing
yoko.cabal view
@@ -1,5 +1,5 @@ name: yoko-version: 0.3.2.1+version: 0.3.2.2 synopsis: Generic Programming with Disbanded Data Types description: