Simon Peyton Jones pushed to branch wip/T26176 at Glasgow Haskell Compiler / GHC

Commits:

2 changed files:

Changes:

  • testsuite/tests/typecheck/should_compile/T14010.hs
    1
    +{-# LANGUAGE NoImplicitPrelude, PolyKinds, DataKinds, TypeFamilies,
    
    2
    +             UndecidableSuperClasses, RankNTypes, TypeOperators,
    
    3
    +             FlexibleContexts, TypeSynonymInstances, FlexibleInstances,
    
    4
    +             UndecidableInstances #-}
    
    5
    +module Monolith where
    
    6
    +
    
    7
    +import Data.Kind (Type)
    
    8
    +import GHC.Exts (Constraint)
    
    9
    +
    
    10
    +type family (~>) :: c -> c -> Type
    
    11
    +
    
    12
    +type instance (~>) = (->)
    
    13
    +type instance (~>) = ArrPair
    
    14
    +
    
    15
    +type family Fst (p :: (a, b)) :: a where
    
    16
    +  Fst '(x, _) = x
    
    17
    +
    
    18
    +type family Snd (p :: (a, b)) :: b where
    
    19
    +  Snd '(_, y) = y
    
    20
    +
    
    21
    +data ArrPair a b = ArrPair (Fst a ~> Fst b) (Snd a ~> Snd b)
    
    22
    +
    
    23
    +type family Super c :: Constraint where
    
    24
    +  Super Type = ()
    
    25
    +  Super (c, d) = (Category c, Category d)
    
    26
    +
    
    27
    +class Super cat => Category cat where
    
    28
    +  id :: forall (a :: cat). a ~> a
    
    29
    +
    
    30
    +instance Category Type where
    
    31
    +  id = \x -> x
    
    32
    +
    
    33
    +instance (Category c, Category d) => Category (c, d) where
    
    34
    +  id = ArrPair id id
    
    35
    +
    
    36
    +-- The commented out version worked
    
    37
    +-- class Category (c, d) => Functor (f :: c -> d) where
    
    38
    +class (Category c, Category d) => Functor (f :: c -> d) where
    
    39
    +  map :: (a ~> b) -> (f a ~> f b)
    
    40
    +
    
    41
    +data OnSnd f a b = OnSnd (f '(a, b))
    
    42
    +
    
    43
    +instance Functor (f :: (c, d) -> Type) => Functor (OnSnd f a) where
    
    44
    +  map f (OnSnd x) = OnSnd (map (ArrPair id f) x)

  • testsuite/tests/typecheck/should_compile/all.T
    ... ... @@ -939,3 +939,4 @@ test('T25960', normal, compile, [''])
    939 939
     test('T26020', normal, compile, [''])
    
    940 940
     test('T26020a', [extra_files(['T26020a_help.hs'])], multimod_compile, ['T26020a', '-v0'])
    
    941 941
     test('T25992', normal, compile, [''])
    
    942
    +test('T14010', normal, compile, [''])