blob: 89153d4d0b37439e117f87cc0030e83e8fbb830b (
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
|
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-}
-- this is needed because |FamHelper a x| /< |Fam a x|
-- This file compiled with -dunique-increment=-1 made GHC crash before
module T11361 where
import Data.Kind (Type)
class Cls a where
type Fam a b :: Type
-- Multiple defaults!
type Fam a x = FamHelper a x
type family FamHelper a x
type instance FamHelper a Bool = Maybe a
type instance FamHelper a Int = (String, a)
instance Cls Int where
-- Gets type family from default
inc :: (Fam a Bool ~ Maybe Int, Fam a Int ~ (String, Int)) => a -> Fam a Bool -> Fam a Int -> Fam a Bool
inc _proxy (Just x) (_, y) = Just (x + y + 1)
inc _proxy Nothing (_, y) = Just y
foo :: Maybe Int -> (String, Int) -> Maybe Int
foo = inc (undefined :: Int)
|