Commit 475e4b98 authored by Simon Peyton Jones's avatar Simon Peyton Jones
Browse files

Add FlexibleInstances to tests that need it

parent 7e208ced
{-# LANGUAGE Rank2Types, TypeSynonymInstances #-}
{-# LANGUAGE Rank2Types, TypeSynonymInstances, FlexibleInstances #-}
{-# LANGUAGE TypeFamilies, GeneralizedNewtypeDeriving #-}
module Bug2 where
......
{-# LANGUAGE RebindableSyntax, NPlusKPatterns, TypeSynonymInstances,
{-# LANGUAGE RebindableSyntax, NPlusKPatterns, FlexibleInstances,
MultiParamTypeClasses, FunctionalDependencies #-}
module Main where
......
......@@ -3,23 +3,44 @@
This file is part of the Streaming Component Combinators (SCC) project.
The SCC project is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later
version.
SCC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with SCC. If not, see
<http://www.gnu.org/licenses/>.
The SCC project is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
SCC is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
License for more details.
You should have received a copy of the GNU General Public License
along with SCC. If not, see <http://www.gnu.org/licenses/>.
-}
-- | Module "Trampoline" defines the pipe computations and their basic building blocks.
{-# LANGUAGE ScopedTypeVariables, Rank2Types, MultiParamTypeClasses, TypeFamilies, KindSignatures,
FlexibleContexts, FlexibleInstances, OverlappingInstances, UndecidableInstances
{-# LANGUAGE ScopedTypeVariables, Rank2Types, MultiParamTypeClasses,
TypeFamilies, KindSignatures, FlexibleContexts,
FlexibleInstances, OverlappingInstances, UndecidableInstances
#-}
{- Somewhere we get:
Wanted: AncestorFunctor (EitherFunctor a (TryYield a)) d
This should not reduce because of overlapping instances
If it (erroneously) does reduce, via dfun2 we get
Wanted: Functor (EitherFunctor a (TryYield a)
Functor d'
Functor d
d ~ EitherFunctor d' s
AncestorFunctor (EitherFunctor a (TryYield a) d'
And that gives an infinite loop in the type checker!
-}
module Main where
import Control.Monad (liftM, liftM2, when)
......@@ -27,6 +48,28 @@ import Control.Monad (liftM, liftM2, when)
import Debug.Trace (trace)
-------------
class (Functor a, Functor d) => AncestorFunctor a d where
liftFunctor :: a x -> d x
-- dfun 1
instance Functor a => AncestorFunctor a a where
liftFunctor = trace "liftFunctor id" . id
-- dfun 2
instance ( Functor a
, Functor d'
, Functor d
, d ~ EitherFunctor d' s
, AncestorFunctor a d')
=> AncestorFunctor a d where
liftFunctor = LeftF . (trace "liftFunctor other" . liftFunctor :: a x -> d' x)
-------------
newtype Identity a = Identity { runIdentity :: a }
instance Monad Identity where
return a = Identity a
......@@ -114,14 +157,6 @@ out (Trampoline ml) = Trampoline (liftM inject ml)
inject (Done x) = Done x
inject (Suspend l) = Suspend (LeftF $ fmap out l)
class (Functor a, Functor d) => AncestorFunctor a d where
liftFunctor :: a x -> d x
instance Functor a => AncestorFunctor a a where
liftFunctor = trace "liftFunctor id" . id
instance (Functor a, Functor d', Functor d, d ~ EitherFunctor d' s, AncestorFunctor a d') => AncestorFunctor a d where
liftFunctor = LeftF . (trace "liftFunctor other" . liftFunctor :: a x -> d' x)
liftOut :: forall m a d x. (Monad m, Functor a, AncestorFunctor a d) => Trampoline m a x -> Trampoline m d x
liftOut (Trampoline ma) = trace "liftOut" $ Trampoline (liftM inject ma)
where inject :: TrampolineState m a x -> TrampolineState m d x
......
{-# LANGUAGE TemplateHaskell, UndecidableInstances, TypeSynonymInstances #-}
{-# LANGUAGE TemplateHaskell, UndecidableInstances, FlexibleInstances, TypeSynonymInstances #-}
module TH_spliceDecl4 where
......
{-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies,
TypeSynonymInstances #-}
FlexibleInstances, TypeSynonymInstances #-}
-- This one made GHC 6.4 loop becuause Unify.unify
-- didn't deal correctly with unifying
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment