Commit 2c2f3cea authored by Simon Peyton Jones's avatar Simon Peyton Jones
Browse files

Minimise provided dictionaries in pattern synonyms

Trac #14394 showed that it's possible to get redundant
constraints in the inferred provided constraints of a pattern
synonym.  This patch removes the redundancy with mkMinimalBySCs.

To do this I had to generalise the type of mkMinimalBySCs slightly.
And, to reduce confusing reversal, I made it stable: it now returns
its result in the same order as its input.  That led to a raft of
error message wibbles, mostly for the better.
parent 30058b0e
...@@ -704,7 +704,7 @@ simplifyDeriv pred tvs thetas ...@@ -704,7 +704,7 @@ simplifyDeriv pred tvs thetas
vcat [ ppr tvs_skols, ppr residual_simple, ppr good, ppr bad ] vcat [ ppr tvs_skols, ppr residual_simple, ppr good, ppr bad ]
-- Return the good unsolved constraints (unskolemizing on the way out.) -- Return the good unsolved constraints (unskolemizing on the way out.)
; let min_theta = mkMinimalBySCs (bagToList good) ; let min_theta = mkMinimalBySCs id (bagToList good)
-- An important property of mkMinimalBySCs (used above) is that in -- An important property of mkMinimalBySCs (used above) is that in
-- addition to removing constraints that are made redundant by -- addition to removing constraints that are made redundant by
-- superclass relationships, it also removes _duplicate_ -- superclass relationships, it also removes _duplicate_
......
...@@ -2374,10 +2374,7 @@ mkDictErr ctxt cts ...@@ -2374,10 +2374,7 @@ mkDictErr ctxt cts
-- When simplifying [W] Ord (Set a), we need -- When simplifying [W] Ord (Set a), we need
-- [W] Eq a, [W] Ord a -- [W] Eq a, [W] Ord a
-- but we really only want to report the latter -- but we really only want to report the latter
elim_superclasses cts elim_superclasses cts = mkMinimalBySCs ctPred cts
= filter (\ct -> any (eqType (ctPred ct)) min_preds) cts
where
min_preds = mkMinimalBySCs (map ctPred cts)
mk_dict_err :: ReportErrCtxt -> (Ct, ClsInstLookupResult) mk_dict_err :: ReportErrCtxt -> (Ct, ClsInstLookupResult)
-> TcM (ReportErrCtxt, SDoc) -> TcM (ReportErrCtxt, SDoc)
......
...@@ -20,6 +20,7 @@ import TcPat ...@@ -20,6 +20,7 @@ import TcPat
import Type( mkEmptyTCvSubst, tidyTyVarBinders, tidyTypes, tidyType ) import Type( mkEmptyTCvSubst, tidyTyVarBinders, tidyTypes, tidyType )
import TcRnMonad import TcRnMonad
import TcSigs( emptyPragEnv, completeSigFromId ) import TcSigs( emptyPragEnv, completeSigFromId )
import TcType( mkMinimalBySCs )
import TcEnv import TcEnv
import TcMType import TcMType
import TcHsSyn( zonkTyVarBindersX, zonkTcTypeToTypes import TcHsSyn( zonkTyVarBindersX, zonkTcTypeToTypes
...@@ -88,18 +89,44 @@ tcInferPatSynDecl PSB{ psb_id = lname@(L _ name), psb_args = details, ...@@ -88,18 +89,44 @@ tcInferPatSynDecl PSB{ psb_id = lname@(L _ name), psb_args = details,
; let (ex_tvs, prov_dicts) = tcCollectEx lpat' ; let (ex_tvs, prov_dicts) = tcCollectEx lpat'
ex_tv_set = mkVarSet ex_tvs ex_tv_set = mkVarSet ex_tvs
univ_tvs = filterOut (`elemVarSet` ex_tv_set) qtvs univ_tvs = filterOut (`elemVarSet` ex_tv_set) qtvs
prov_theta = map evVarPred prov_dicts
req_theta = map evVarPred req_dicts req_theta = map evVarPred req_dicts
; prov_dicts <- mapM zonkId prov_dicts
; let filtered_prov_dicts = mkMinimalBySCs evVarPred prov_dicts
prov_theta = map evVarPred filtered_prov_dicts
-- Filtering: see Note [Remove redundant provided dicts]
; traceTc "tcInferPatSynDecl }" $ (ppr name $$ ppr ex_tvs) ; traceTc "tcInferPatSynDecl }" $ (ppr name $$ ppr ex_tvs)
; tc_patsyn_finish lname dir is_infix lpat' ; tc_patsyn_finish lname dir is_infix lpat'
(mkTyVarBinders Inferred univ_tvs (mkTyVarBinders Inferred univ_tvs
, req_theta, ev_binds, req_dicts) , req_theta, ev_binds, req_dicts)
(mkTyVarBinders Inferred ex_tvs (mkTyVarBinders Inferred ex_tvs
, mkTyVarTys ex_tvs, prov_theta, map EvId prov_dicts) , mkTyVarTys ex_tvs, prov_theta, map EvId filtered_prov_dicts)
(map nlHsVar args, map idType args) (map nlHsVar args, map idType args)
pat_ty rec_fields } pat_ty rec_fields }
{- Note [Remove redundant provided dicts]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Recall that
HRefl :: forall k1 k2 (a1:k1) (a2:k2). (k1 ~ k2, a1 ~ a2)
=> a1 :~~: a2
(NB: technically the (k1~k2) existential dictionary is not necessary,
but it's there at the moment.)
Now consider (Trac #14394):
pattern Foo = HRefl
in a non-poly-kinded module. We don't want to get
pattern Foo :: () => (* ~ *, b ~ a) => a :~~: b
with that redundant (* ~ *). We'd like to remove it; hence the call to
mkMinimalWithSCs.
Similarly consider
data S a where { MkS :: Ord a => a -> S a }
pattern Bam x y <- (MkS (x::a), MkS (y::a)))
The pattern (Bam x y) binds two (Ord a) dictionaries, but we only
need one. Agian mkMimimalWithSCs removes the redundant one.
-}
tcCheckPatSynDecl :: PatSynBind GhcRn GhcRn tcCheckPatSynDecl :: PatSynBind GhcRn GhcRn
-> TcPatSynInfo -> TcPatSynInfo
...@@ -332,7 +359,7 @@ tc_patsyn_finish lname dir is_infix lpat' ...@@ -332,7 +359,7 @@ tc_patsyn_finish lname dir is_infix lpat'
(ze, univ_tvs') <- zonkTyVarBindersX emptyZonkEnv univ_tvs (ze, univ_tvs') <- zonkTyVarBindersX emptyZonkEnv univ_tvs
; req_theta' <- zonkTcTypeToTypes ze req_theta ; req_theta' <- zonkTcTypeToTypes ze req_theta
; (ze, ex_tvs') <- zonkTyVarBindersX ze ex_tvs ; (ze, ex_tvs') <- zonkTyVarBindersX ze ex_tvs
; prov_theta' <- zonkTcTypeToTypes ze prov_theta ; prov_theta' <- zonkTcTypeToTypes ze prov_theta
; pat_ty' <- zonkTcTypeToType ze pat_ty ; pat_ty' <- zonkTcTypeToType ze pat_ty
; arg_tys' <- zonkTcTypeToTypes ze arg_tys ; arg_tys' <- zonkTcTypeToTypes ze arg_tys
...@@ -813,10 +840,13 @@ tcCheckPatSynPat = go ...@@ -813,10 +840,13 @@ tcCheckPatSynPat = go
go = addLocM go1 go = addLocM go1
go1 :: Pat GhcRn -> TcM () go1 :: Pat GhcRn -> TcM ()
-- See Note [Bad patterns]
go1 p@(AsPat _ _) = asPatInPatSynErr p
go1 p@NPlusKPat{} = nPlusKPatInPatSynErr p
go1 (ConPatIn _ info) = mapM_ go (hsConPatArgs info) go1 (ConPatIn _ info) = mapM_ go (hsConPatArgs info)
go1 VarPat{} = return () go1 VarPat{} = return ()
go1 WildPat{} = return () go1 WildPat{} = return ()
go1 p@(AsPat _ _) = asPatInPatSynErr p
go1 (LazyPat pat) = go pat go1 (LazyPat pat) = go pat
go1 (ParPat pat) = go pat go1 (ParPat pat) = go pat
go1 (BangPat pat) = go pat go1 (BangPat pat) = go pat
...@@ -833,7 +863,6 @@ tcCheckPatSynPat = go ...@@ -833,7 +863,6 @@ tcCheckPatSynPat = go
= do addModFinalizersWithLclEnv mod_finalizers = do addModFinalizersWithLclEnv mod_finalizers
go1 pat go1 pat
| otherwise = panic "non-pattern from spliced thing" | otherwise = panic "non-pattern from spliced thing"
go1 p@NPlusKPat{} = nPlusKPatInPatSynErr p
go1 ConPatOut{} = panic "ConPatOut in output of renamer" go1 ConPatOut{} = panic "ConPatOut in output of renamer"
go1 SigPatOut{} = panic "SigPatOut in output of renamer" go1 SigPatOut{} = panic "SigPatOut in output of renamer"
go1 CoPat{} = panic "CoPat in output of renamer" go1 CoPat{} = panic "CoPat in output of renamer"
...@@ -850,6 +879,23 @@ nPlusKPatInPatSynErr pat ...@@ -850,6 +879,23 @@ nPlusKPatInPatSynErr pat
hang (text "Pattern synonym definition cannot contain n+k-pattern:") hang (text "Pattern synonym definition cannot contain n+k-pattern:")
2 (ppr pat) 2 (ppr pat)
{- Note [Bad patterns]
~~~~~~~~~~~~~~~~~~~~~~
We don't currently allow as-patterns or n+k patterns in a pattern synonym.
Reason: consider
pattern P x y = x@(Just y)
What would
f (P Nothing False) = e
mean? Presumably something like
f Nothing@(Just False) = e
But as-patterns don't allow a pattern before the @ sign! Perhaps they
should -- with p1@p2 meaning match both p1 and p2 -- but they don't
currently. Hence bannning them in pattern synonyms. Actually lifting
the restriction would be simple and well-defined. See Trac #9793.
-}
nonBidirectionalErr :: Outputable name => name -> TcM a nonBidirectionalErr :: Outputable name => name -> TcM a
nonBidirectionalErr name = failWithTc $ nonBidirectionalErr name = failWithTc $
text "non-bidirectional pattern synonym" text "non-bidirectional pattern synonym"
......
...@@ -832,7 +832,7 @@ decideQuantification infer_mode rhs_tclvl name_taus psigs candidates ...@@ -832,7 +832,7 @@ decideQuantification infer_mode rhs_tclvl name_taus psigs candidates
-- into quantified skolems, so we have to zonk again -- into quantified skolems, so we have to zonk again
; candidates <- TcM.zonkTcTypes candidates ; candidates <- TcM.zonkTcTypes candidates
; let theta = pickQuantifiablePreds (mkVarSet qtvs) $ ; let theta = pickQuantifiablePreds (mkVarSet qtvs) $
mkMinimalBySCs $ -- See Note [Minimize by Superclasses] mkMinimalBySCs id $ -- See Note [Minimize by Superclasses]
candidates candidates
; traceTc "decideQuantification" ; traceTc "decideQuantification"
......
...@@ -15,7 +15,7 @@ The "tc" prefix is for "TypeChecker", because the type checker ...@@ -15,7 +15,7 @@ The "tc" prefix is for "TypeChecker", because the type checker
is the principal client. is the principal client.
-} -}
{-# LANGUAGE CPP, MultiWayIf, FlexibleContexts #-} {-# LANGUAGE CPP, ScopedTypeVariables, MultiWayIf, FlexibleContexts #-}
module TcType ( module TcType (
-------------------------------- --------------------------------
...@@ -1949,29 +1949,47 @@ pickCapturedPreds qtvs theta ...@@ -1949,29 +1949,47 @@ pickCapturedPreds qtvs theta
-- Superclasses -- Superclasses
type PredWithSCs = (PredType, [PredType]) type PredWithSCs a = (PredType, [PredType], a)
mkMinimalBySCs :: [PredType] -> [PredType] mkMinimalBySCs :: forall a. (a -> PredType) -> [a] -> [a]
-- Remove predicates that can be deduced from others by superclasses, -- Remove predicates that
-- including duplicate predicates. The result is a subset of the input. --
mkMinimalBySCs ptys = go preds_with_scs [] -- - are the same as another predicate
--
-- - can be deduced from another by superclasses,
--
-- - are a reflexive equality (e.g * ~ *)
-- (see Note [Remove redundant provided dicts] in PatSyn)
--
-- The result is a subset of the input.
-- The 'a' is just paired up with the PredType;
-- typically it might be a dictionary Id
mkMinimalBySCs get_pred xs = go preds_with_scs []
where where
preds_with_scs :: [PredWithSCs] preds_with_scs :: [PredWithSCs a]
preds_with_scs = [ (pred, pred : transSuperClasses pred) preds_with_scs = [ (pred, pred : transSuperClasses pred, x)
| pred <- ptys ] | x <- xs
, let pred = get_pred x ]
go :: [PredWithSCs] -- Work list
-> [PredWithSCs] -- Accumulating result go :: [PredWithSCs a] -- Work list
-> [PredType] -> [PredWithSCs a] -- Accumulating result
go [] min_preds = map fst min_preds -> [a]
go (work_item@(p,_) : work_list) min_preds go [] min_preds
= reverse (map thdOf3 min_preds)
-- The 'reverse' isn't strictly necessary, but it
-- means that the results are returned in the same
-- order as the input, which is generally saner
go (work_item@(p,_,_) : work_list) min_preds
| EqPred _ t1 t2 <- classifyPredType p
, t1 `tcEqType` t2 -- See Note [Discard reflexive equalities]
= go work_list min_preds
| p `in_cloud` work_list || p `in_cloud` min_preds | p `in_cloud` work_list || p `in_cloud` min_preds
= go work_list min_preds = go work_list min_preds
| otherwise | otherwise
= go work_list (work_item : min_preds) = go work_list (work_item : min_preds)
in_cloud :: PredType -> [PredWithSCs] -> Bool in_cloud :: PredType -> [PredWithSCs a] -> Bool
in_cloud p ps = or [ p `eqType` p' | (_, scs) <- ps, p' <- scs ] in_cloud p ps = or [ p `tcEqType` p' | (_, scs, _) <- ps, p' <- scs ]
transSuperClasses :: PredType -> [PredType] transSuperClasses :: PredType -> [PredType]
-- (transSuperClasses p) returns (p's superclasses) not including p -- (transSuperClasses p) returns (p's superclasses) not including p
......
...@@ -9,37 +9,37 @@ TYPE SIGNATURES ...@@ -9,37 +9,37 @@ TYPE SIGNATURES
forall (f :: * -> *). Applicative f => (Int -> f Int) -> f Int forall (f :: * -> *). Applicative f => (Int -> f Int) -> f Int
test2 :: test2 ::
forall (f :: * -> *) t b. forall (f :: * -> *) t b.
(Num b, Num t, Applicative f) => (Applicative f, Num t, Num b) =>
(t -> f b) -> f b (t -> f b) -> f b
test2a :: test2a ::
forall (f :: * -> *) t b. forall (f :: * -> *) t b.
(Num b, Num t, Functor f) => (Functor f, Num t, Num b) =>
(t -> f b) -> f b (t -> f b) -> f b
test2b :: test2b ::
forall (m :: * -> *) t a. (Num t, Monad m) => (t -> a) -> m a forall (m :: * -> *) t a. (Monad m, Num t) => (t -> a) -> m a
test2c :: test2c ::
forall (f :: * -> *) t b. forall (f :: * -> *) t b.
(Num b, Num t, Functor f) => (Functor f, Num t, Num b) =>
(t -> f b) -> f b (t -> f b) -> f b
test2d :: test2d ::
forall (f :: * -> *) t1 b t2. forall (f :: * -> *) t1 b t2.
(Num b, Num t1, Functor f) => (Functor f, Num t1, Num b) =>
(t1 -> f t2) -> f b (t1 -> f t2) -> f b
test3 :: test3 ::
forall (m :: * -> *) t1 t2 a. forall (m :: * -> *) t1 t2 a.
(Num t1, Monad m) => (Monad m, Num t1) =>
(t1 -> m t2) -> (t2 -> t2 -> m a) -> m a (t1 -> m t2) -> (t2 -> t2 -> m a) -> m a
test4 :: test4 ::
forall (m :: * -> *) t a1 a2. forall (m :: * -> *) t a1 a2.
(Num t, Monad m) => (Monad m, Num t) =>
(t -> m a1) -> (a1 -> a1 -> m a2) -> m a2 (t -> m a1) -> (a1 -> a1 -> m a2) -> m a2
test5 :: test5 ::
forall (m :: * -> *) t a1 a2. forall (m :: * -> *) t a1 a2.
(Num t, Monad m) => (Monad m, Num t) =>
(t -> m a1) -> (a1 -> a1 -> m a2) -> m a2 (t -> m a1) -> (a1 -> a1 -> m a2) -> m a2
test6 :: test6 ::
forall (m :: * -> *) a p. forall (m :: * -> *) a p.
(Num (m a), Monad m) => (Monad m, Num (m a)) =>
(m a -> m (m a)) -> p -> m a (m a -> m (m a)) -> p -> m a
TYPE CONSTRUCTORS TYPE CONSTRUCTORS
COERCION AXIOMS COERCION AXIOMS
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
drvfail004.hs:8:12: error: drvfail004.hs:8:12: error:
• Could not deduce (Eq (Foo a b)) • Could not deduce (Eq (Foo a b))
arising from the 'deriving' clause of a data type declaration arising from the 'deriving' clause of a data type declaration
from the context: (Ord b, Ord a) from the context: (Ord a, Ord b)
bound by the deriving clause for ‘Ord (Foo a b)’ bound by the deriving clause for ‘Ord (Foo a b)’
at drvfail004.hs:8:12-14 at drvfail004.hs:8:12-14
Possible fix: Possible fix:
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
TYPE SIGNATURES TYPE SIGNATURES
test2 :: test2 ::
forall (f :: * -> *) t b. forall (f :: * -> *) t b.
(Num b, Num t, Applicative f) => (Applicative f, Num t, Num b) =>
(t -> f b) -> f b (t -> f b) -> f b
TYPE CONSTRUCTORS TYPE CONSTRUCTORS
COERCION AXIOMS COERCION AXIOMS
...@@ -13,7 +13,7 @@ Dependent packages: [base-4.11.0.0, ghc-prim-0.5.2.0, ...@@ -13,7 +13,7 @@ Dependent packages: [base-4.11.0.0, ghc-prim-0.5.2.0,
TYPE SIGNATURES TYPE SIGNATURES
test2 :: test2 ::
forall (f :: * -> *) t b. forall (f :: * -> *) t b.
(Num b, Num t, Applicative f) => (Applicative f, Num t, Num b) =>
(t -> f b) -> f b (t -> f b) -> f b
TYPE CONSTRUCTORS TYPE CONSTRUCTORS
COERCION AXIOMS COERCION AXIOMS
......
mapM :: (Monad m, Traversable t) => (a -> m b) -> t a -> m (t b) mapM :: (Traversable t, Monad m) => (a -> m b) -> t a -> m (t b)
mapM :: Monad m => (a -> m b) -> [a] -> m [b] mapM :: Monad m => (a -> m b) -> [a] -> m [b]
length :: [a] -> Int length :: [a] -> Int
foo :: Double -> Double foo :: Double -> Double
...@@ -4,14 +4,14 @@ pattern P :: Bool -- Defined at <interactive>:16:1 ...@@ -4,14 +4,14 @@ pattern P :: Bool -- Defined at <interactive>:16:1
pattern Pe :: a -> Ex -- Defined at <interactive>:17:1 pattern Pe :: a -> Ex -- Defined at <interactive>:17:1
pattern Pu :: p -> p -- Defined at <interactive>:18:1 pattern Pu :: p -> p -- Defined at <interactive>:18:1
pattern Pue :: a -> a1 -> (a, Ex) -- Defined at <interactive>:19:1 pattern Pue :: a -> a1 -> (a, Ex) -- Defined at <interactive>:19:1
pattern Pur :: (Num a, Eq a) => a -> [a] pattern Pur :: (Eq a, Num a) => a -> [a]
-- Defined at <interactive>:20:1 -- Defined at <interactive>:20:1
pattern Purp :: (Num a, Eq a) => Show a1 => a pattern Purp :: (Eq a, Num a) => Show a1 => a
-> a1 -> ([a], UnivProv a1) -> a1 -> ([a], UnivProv a1)
-- Defined at <interactive>:21:1 -- Defined at <interactive>:21:1
pattern Pure :: (Num a, Eq a) => a -> a1 -> ([a], Ex) pattern Pure :: (Eq a, Num a) => a -> a1 -> ([a], Ex)
-- Defined at <interactive>:22:1 -- Defined at <interactive>:22:1
pattern Purep :: (Num a, Eq a) => Show a1 => a pattern Purep :: (Eq a, Num a) => Show a1 => a
-> a1 -> ([a], ExProv) -> a1 -> ([a], ExProv)
-- Defined at <interactive>:23:1 -- Defined at <interactive>:23:1
pattern Pep :: () => Show a => a -> ExProv pattern Pep :: () => Show a => a -> ExProv
...@@ -29,15 +29,15 @@ pattern Pe :: () => forall {a}. a -> Ex ...@@ -29,15 +29,15 @@ pattern Pe :: () => forall {a}. a -> Ex
pattern Pu :: forall {p}. p -> p -- Defined at <interactive>:18:1 pattern Pu :: forall {p}. p -> p -- Defined at <interactive>:18:1
pattern Pue :: forall {a}. () => forall {a1}. a -> a1 -> (a, Ex) pattern Pue :: forall {a}. () => forall {a1}. a -> a1 -> (a, Ex)
-- Defined at <interactive>:19:1 -- Defined at <interactive>:19:1
pattern Pur :: forall {a}. (Num a, Eq a) => a -> [a] pattern Pur :: forall {a}. (Eq a, Num a) => a -> [a]
-- Defined at <interactive>:20:1 -- Defined at <interactive>:20:1
pattern Purp :: forall {a} {a1}. (Num a, Eq a) => Show a1 => a pattern Purp :: forall {a} {a1}. (Eq a, Num a) => Show a1 => a
-> a1 -> ([a], UnivProv a1) -> a1 -> ([a], UnivProv a1)
-- Defined at <interactive>:21:1 -- Defined at <interactive>:21:1
pattern Pure :: forall {a}. (Num a, Eq a) => forall {a1}. a pattern Pure :: forall {a}. (Eq a, Num a) => forall {a1}. a
-> a1 -> ([a], Ex) -> a1 -> ([a], Ex)
-- Defined at <interactive>:22:1 -- Defined at <interactive>:22:1
pattern Purep :: forall {a}. (Num a, Eq a) => forall {a1}. Show pattern Purep :: forall {a}. (Eq a, Num a) => forall {a1}. Show
a1 => a -> a1 -> ([a], ExProv) a1 => a -> a1 -> ([a], ExProv)
-- Defined at <interactive>:23:1 -- Defined at <interactive>:23:1
pattern Pep :: () => forall {a}. Show a => a -> ExProv pattern Pep :: () => forall {a}. Show a => a -> ExProv
......
mapM mapM
:: forall {t :: * -> *} {m :: * -> *} {a} {b}. :: forall {t :: * -> *} {m :: * -> *} {a} {b}.
(Monad m, Traversable t) => (Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b) (a -> m b) -> t a -> m (t b)
mapM mapM
:: forall (t :: * -> *). :: forall (t :: * -> *).
......
...@@ -35,15 +35,15 @@ instance ∀ i (c ∷ Meta) (f ∷ ★ → ★). Functor f ⇒ Functor (M1 i c f ...@@ -35,15 +35,15 @@ instance ∀ i (c ∷ Meta) (f ∷ ★ → ★). Functor f ⇒ Functor (M1 i c f
-- Defined in ‘GHC.Generics’ -- Defined in ‘GHC.Generics’
instance ∀ i c. Functor (K1 i c) -- Defined in ‘GHC.Generics’ instance ∀ i c. Functor (K1 i c) -- Defined in ‘GHC.Generics’
instance ∀ (f ∷ ★ → ★) (g ∷ ★ → ★). instance ∀ (f ∷ ★ → ★) (g ∷ ★ → ★).
(Functor g, Functor f) ⇒ (Functor f, Functor g) ⇒
Functor (f :.: g) Functor (f :.: g)
-- Defined in ‘GHC.Generics’ -- Defined in ‘GHC.Generics’
instance ∀ (f ∷ ★ → ★) (g ∷ ★ → ★). instance ∀ (f ∷ ★ → ★) (g ∷ ★ → ★).
(Functor g, Functor f) ⇒ (Functor f, Functor g) ⇒
Functor (f :+: g) Functor (f :+: g)
-- Defined in ‘GHC.Generics’ -- Defined in ‘GHC.Generics’
instance ∀ (f ∷ ★ → ★) (g ∷ ★ → ★). instance ∀ (f ∷ ★ → ★) (g ∷ ★ → ★).
(Functor g, Functor f) ⇒ (Functor f, Functor g) ⇒
Functor (f :*: g) Functor (f :*: g)
-- Defined in ‘GHC.Generics’ -- Defined in ‘GHC.Generics’
instance ∀ a. Functor (Either a) -- Defined in ‘Data.Either’ instance ∀ a. Functor (Either a) -- Defined in ‘Data.Either’
......
...@@ -4,7 +4,7 @@ TYPE SIGNATURES ...@@ -4,7 +4,7 @@ TYPE SIGNATURES
emptyL :: forall a. ListColl a emptyL :: forall a. ListColl a
insert :: forall c. Coll c => Elem c -> c -> c insert :: forall c. Coll c => Elem c -> c -> c
test2 :: test2 ::
forall c a b. (Elem c ~ (a, b), Num b, Num a, Coll c) => c -> c forall c a b. (Coll c, Num a, Num b, Elem c ~ (a, b)) => c -> c
TYPE CONSTRUCTORS TYPE CONSTRUCTORS
class Coll c where class Coll c where
type family Elem c :: * open type family Elem c :: * open
......
T8889.hs:12:1: warning: [-Wmissing-signatures (in -Wall)] T8889.hs:12:1: warning: [-Wmissing-signatures (in -Wall)]
Top-level binding with no type signature: Top-level binding with no type signature:
f :: (C f, C_fmap f a) => (a -> b) -> f a -> f b f :: (C_fmap f a, C f) => (a -> b) -> f a -> f b
...@@ -9,5 +9,5 @@ T1897b.hs:16:1: error: ...@@ -9,5 +9,5 @@ T1897b.hs:16:1: error:
To defer the ambiguity check to use sites, enable AllowAmbiguousTypes To defer the ambiguity check to use sites, enable AllowAmbiguousTypes
When checking the inferred type When checking the inferred type
isValid :: forall (t :: * -> *) a. isValid :: forall (t :: * -> *) a.
(Bug a, Foldable t) => (Foldable t, Bug a) =>
t (Depend a) -> Bool t (Depend a) -> Bool
TYPE SIGNATURES TYPE SIGNATURES
arbitCs1 :: forall a. (Eq a, Enum a, Show a) => a -> String arbitCs1 :: forall a. (Show a, Enum a, Eq a) => a -> String
arbitCs2 :: forall a. (Show a, Enum a, Eq a) => a -> String arbitCs2 :: forall a. (Show a, Enum a, Eq a) => a -> String
arbitCs3 :: forall a. (Show a, Enum a, Eq a) => a -> String arbitCs3 :: forall a. (Show a, Enum a, Eq a) => a -> String
arbitCs4 :: forall a. (Eq a, Show a, Enum a) => a -> String arbitCs4 :: forall a. (Eq a, Show a, Enum a) => a -> String
......
...@@ -21,8 +21,8 @@ TYPE SIGNATURES ...@@ -21,8 +21,8 @@ TYPE SIGNATURES
>> :: forall (m :: * -> *) a b. Monad m => m a -> m b -> m b >> :: forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>= :: >>= ::
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
^ :: forall b a. (Num a, Integral b) => a -> b -> a ^ :: forall b a. (Integral b, Num a) => a -> b -> a
^^ :: forall a b. (Integral b, Fractional a) => a -> b -> a ^^ :: forall a b. (Fractional a, Integral b) => a -> b -> a
abs :: forall a. Num a => a -> a abs :: forall a. Num a => a -> a
acos :: forall a. Floating a => a -> a acos :: forall a. Floating a => a -> a
acosh :: forall a. Floating a => a -> a acosh :: forall a. Floating a => a -> a
...@@ -39,7 +39,7 @@ TYPE SIGNATURES ...@@ -39,7 +39,7 @@ TYPE SIGNATURES
atan2 :: forall a. RealFloat a => a -> a -> a atan2 :: forall a. RealFloat a => a -> a -> a
atanh :: forall a. Floating a => a -> a atanh :: forall a. Floating a => a -> a
break :: forall a. (a -> Bool) -> [a] -> ([a], [a]) break :: forall a. (a -> Bool) -> [a] -> ([a], [a])
ceiling :: forall a b. (Integral b, RealFrac a) => a -> b ceiling :: forall a b. (RealFrac a, Integral b) => a -> b
compare :: forall a. Ord a => a -> a -> Ordering compare :: forall a. Ord a => a -> a -> Ordering
concat :: forall (t :: * -> *) a. P.Foldable t => t [a] -> [a] concat :: forall (t :: * -> *) a. P.Foldable t => t [a] -> [a]
concatMap :: concatMap ::
...@@ -56,7 +56,7 @@ TYPE SIGNATURES ...@@ -56,7 +56,7 @@ TYPE SIGNATURES
dropWhile :: forall a. (a -> Bool) -> [a] -> [a] dropWhile :: forall a. (a -> Bool) -> [a] -> [a]
either :: forall a c b. (a -> c) -> (b -> c) -> Either a b -> c either :: forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
elem :: elem ::
forall (t :: * -> *) a. (Eq a, P.Foldable t) => a -> t a -> Bool forall (t :: * -> *) a. (P.Foldable t, Eq a) => a -> t a -> Bool
encodeFloat :: forall a. RealFloat a => Integer -> Int -> a encodeFloat :: forall a. RealFloat a => Integer -> Int -> a
enumFrom :: forall a. Enum a => a -> [a] enumFrom :: forall a. Enum a => a -> [a]
enumFromThen :: forall a. Enum a => a -> a -> [a] enumFromThen :: forall a. Enum a => a -> a -> [a]
...@@ -72,7 +72,7 @@ TYPE SIGNATURES ...@@ -72,7 +72,7 @@ TYPE SIGNATURES
floatDigits :: forall a. RealFloat a => a -> Int floatDigits :: forall a. RealFloat a => a -> Int
floatRadix :: forall a. RealFloat a => a -> Integer floatRadix :: forall a. RealFloat a => a -> Integer
floatRange :: forall a. RealFloat a => a -> (Int, Int) floatRange :: forall a. RealFloat a => a -> (Int, Int)
floor :: forall a b. (Integral b, RealFrac a) => a -> b floor :: forall a b. (RealFrac a, Integral b) => a -> b
fmap :: fmap ::
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
foldl :: foldl ::
...@@ -89,7 +89,7 @@ TYPE SIGNATURES ...@@ -89,7 +89,7 @@ TYPE SIGNATURES
forall (t :: * -> *) a. P.Foldable t => (a -> a -> a) -> t a -> a forall (t :: * -> *) a. P.Foldable t => (a -> a -> a) -> t a -> a
fromEnum :: forall a. Enum a => a -> Int fromEnum :: forall a. Enum a => a -> Int
fromInteger :: forall a. Num a => Integer -> a fromInteger :: forall a. Num a => Integer -> a
fromIntegral :: forall a b. (Num b, Integral a) => a -> b fromIntegral :: forall a b. (Integral a, Num b) => a -> b
fromRational :: forall a. Fractional a => Rational -> a fromRational :: forall a. Fractional a => Rational -> a