summaryrefslogtreecommitdiff
path: root/testsuite/tests/quantified-constraints/T17267d.hs
blob: 0a9666eb03d2119e803103182de693118a648311 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
{-# LANGUAGE QuantifiedConstraints #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE DeriveFunctor #-}

-- The instances below have large demands, though I think they're pretty sane.
{-# LANGUAGE UndecidableInstances #-}

-- This test uses recursive dictionaries
-- where we do addSolvedDict before solving sub-goals

module Main where

data Foo f a = Foo (f (Maybe a))
deriving instance Show (f (Maybe a)) => Show (Foo f a)
deriving instance Functor f => Functor (Foo f)

data Bar x a = Pure a | Bar (x (Bar x) a)
-- This Show instance is knarly. Basically we ask @x f@ to preserve Show whenever @f@ preserves Show.
deriving instance (forall f b. (Show b, forall c. Show c => Show (f c))
                            => Show (x f b), Show a)
               => Show (Bar x a)
deriving instance (forall f. Functor f => Functor (x f))
               => Functor (Bar x)

-- I should now be able to get Show and Functor for @Bar Foo@.
-- This will involve mutual recursion between the Show/Functor instances for Foo and Bar.
main :: IO ()
main = print $ fmap (<> " there") $ Bar $ Foo $ Pure $ Just "Hello"