Major patch to add -fwarn-redundant-constraints
[ghc.git] / testsuite / tests / simplCore / should_compile / T8848.hs
1 {-# OPTIONS_GHC -fno-warn-missing-methods #-}
2 {-# OPTIONS_GHC -fno-warn-redundant-constraints #-}
3 {-# LANGUAGE KindSignatures, GADTs, DataKinds, FlexibleInstances, FlexibleContexts #-}
4
5 module T8848 where
6
7 import qualified Control.Applicative as A
8 import qualified Data.Functor as Fun
9
10 data Nat = S Nat | Z
11
12 data Shape (rank :: Nat) a where
13 Nil :: Shape Z a
14 (:*) :: a -> Shape r a -> Shape (S r) a
15
16 instance A.Applicative (Shape Z) where
17 instance A.Applicative (Shape r)=> A.Applicative (Shape (S r)) where
18 instance Fun.Functor (Shape Z) where
19 instance (Fun.Functor (Shape r)) => Fun.Functor (Shape (S r)) where
20
21 map2 :: (A.Applicative (Shape r))=> (a->b ->c) -> (Shape r a) -> (Shape r b) -> (Shape r c )
22 map2 = \f l r -> A.pure f A.<*> l A.<*> r
23
24 {-# SPECIALIZE map2 :: (a->b->c)-> (Shape (S (S Z)) a )-> Shape (S (S Z)) b -> Shape (S (S Z)) c #-}
25
26 map3 :: (a->b->c)-> (Shape (S (S Z)) a )-> Shape (S (S Z)) b -> Shape (S (S Z)) c
27 map3 x y z = map2 x y z