blob: 3c94eb2de8a5200eb5d37b23d62bdbffc9deefc6 (
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
|
{-# LANGUAGE TypeFamilies, ScopedTypeVariables#-}
module T3220 where
import Data.Kind (Type)
class Foo m where
type Bar m :: Type
action :: m -> Bar m -> m
right x m = action m (Right x)
right' :: (Either a b ~ Bar m, Foo m) => b -> m -> m
right' x m = action m (Right x)
instance Foo Int where
type Bar Int = Either Int Int
action m a = either (*) (+) a m
instance Foo Float where
type Bar Float = Either Float Float
action m a = either (*) (+) a m
foo = print $ right (1::Int) (3 :: Int)
bar = print $ right (1::Float) (3 :: Float)
|