summaryrefslogtreecommitdiff
path: root/testsuite/tests/typecheck/should_compile/tc224.hs
blob: 34df398e2b0d17c97a4dec9f02cb59005c11b9af (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
{-# OPTIONS_GHC -XOverloadedStrings #-}
module T where

import Data.String

newtype MyString = MyString String deriving (Eq, Show)
instance IsString MyString where
    fromString = MyString

greet1 :: MyString -> MyString
greet1 "hello" = "world"
greet1 other = other

greet2 :: String -> String
greet2 "hello" = "world"
greet2 other = other

greet3 :: (Eq s, IsString s) => s -> s
greet3 "hello" = "world"
greet3 other = other

test = do
    print $ greet1 "hello"
    print $ greet2 "fool"
    print $ greet3 ("foo" :: String)
    print $ greet3 ("bar" :: MyString)