Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test cases for GHCi data, class, etc.
Test cases for GHCi data, type, newtype, class, instance, deriving, etc declarations.
- Loading branch information
Showing
44 changed files
with
336 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--Testing type synonyms | ||
type Foo = String | ||
let foo = "foo" :: Foo | ||
:t foo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
|
||
<interactive>:1:1: Not in scope: `α' | ||
<interactive>:2:1: Not in scope: `α' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
<interactive>:1:68: | ||
Multiple declarations of `f' | ||
Declared at: <interactive>:1:32 | ||
<interactive>:1:68 | ||
<interactive>:1:108: `f' is not a (visible) method of class `Foo' | ||
|
||
<interactive>:3:68: | ||
Multiple declarations of `f' | ||
Declared at: <interactive>:3:32 | ||
<interactive>:3:68 | ||
|
||
<interactive>:3:108: `f' is not a (visible) method of class `Foo' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
($$$) :: [b -> c] -> [b] -> [c] -- Defined at <interactive>:1:8 | ||
($$$) :: [b -> c] -> [b] -> [c] -- Defined at <interactive>:2:8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--Basic deriving test | ||
data T = A | B deriving Show | ||
show A |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
"A" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--Testing type and constructor shadowing | ||
data T = A | B | ||
data T = B | C | ||
:i A |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
data main::Interactive.T = A | ... | ||
-- Defined at <interactive>:3:10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--Testing more shadowing | ||
data T = A | B | ||
data R = A | C | ||
:i A |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
data R = A | ... -- Defined at <interactive>:4:10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--Testing record fields | ||
data T = A {a :: Int} | ||
:i A | ||
:i a | ||
let a = 3 | ||
:i a | ||
a | ||
data R = B {a :: Int} | ||
:i a | ||
:i T |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
data T = A {...} -- Defined at <interactive>:3:10 | ||
data T = A {a :: Int} -- Defined at <interactive>:3:13 | ||
a :: Integer -- Defined at <interactive>:6:5 | ||
3 | ||
data R = B {a :: Int} -- Defined at <interactive>:9:13 | ||
data T = A {main::Interactive.a :: Int} | ||
-- Defined at <interactive>:3:6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--Testing custom classes and instances as well as data type shadowing | ||
class C a | ||
instance C Int | ||
|
||
data Foo = Bar | Baz | ||
class MyEq a where ; myeq :: a -> a -> Bool ; a `myeq` b = True | ||
instance MyEq Foo | ||
Bar `myeq` Baz | ||
data Foo = Bar | Baz | ||
instance MyEq Foo where ; a `myeq` b = False | ||
Baz `myeq` Bar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
True | ||
False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--Testing flexible and Overlapping instances | ||
class C a where { f :: a -> Int; f _ = 3 } | ||
instance C Int where { f = id } | ||
instance C [Int] | ||
:set -XFlexibleInstances | ||
instance C [Int] | ||
instance C a => C [a] where f xs = length xs | ||
-- ***This should be an overlapping instances error!*** | ||
:set -XOverlappingInstances | ||
instance C a => C [a] where f xs = length xs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
|
||
<interactive>:5:10: | ||
Illegal instance declaration for `C [Int]' | ||
(All instance types must be of the form (T a1 ... an) | ||
where a1 ... an are *distinct type variables*, | ||
and each type variable appears at most once in the instance head. | ||
Use -XFlexibleInstances if you want to disable this.) | ||
In the instance declaration for `C [Int]' | ||
|
||
<interactive>:8:10: | ||
Overlapping instance declarations: | ||
instance C a => C [a] -- Defined at <interactive>:8:10 | ||
instance C [Int] -- Defined at <interactive>:7:10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--Testing standalone deriving | ||
:set -XStandaloneDeriving | ||
data Foo = A | B | C | ||
deriving instance Show Foo | ||
A | ||
C |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
A | ||
C |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--Testing type families and their shadowing | ||
:set -XTypeFamilies | ||
data HTrue | ||
data HFalse | ||
type family AND a b | ||
type instance AND HTrue HTrue = HTrue | ||
type instance AND HTrue HFalse = HFalse | ||
type instance AND HFalse HTrue = HFalse | ||
type instance AND HFalse HFalse = HFalse | ||
type family OR a b | ||
type instance OR HTrue HTrue = HTrue | ||
type instance OR HTrue HFalse = HTrue | ||
type instance OR HFalse HTrue = HTrue | ||
type instance OR HFalse HFalse = HFalse | ||
:t undefined :: AND HTrue HTrue | ||
:t undefined :: AND (OR HFalse HTrue) (OR HTrue HFalse) | ||
let t = undefined :: AND HTrue HTrue | ||
let f = undefined :: AND HTrue HFalse | ||
type instance AND HTrue HTrue = HFalse | ||
:t t | ||
let t = undefined :: AND HTrue HTrue | ||
:t t |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
undefined :: AND HTrue HTrue :: HTrue | ||
undefined :: AND (OR HFalse HTrue) (OR HTrue HFalse) :: HTrue | ||
t :: HTrue | ||
t :: HFalse |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
--Testing GADTs, type families as well as a ton of crazy type stuff | ||
:set -XGADTs | ||
:set -XTypeFamilies | ||
:set -XOverlappingInstances | ||
:set -XFunctionalDependencies | ||
:set -XFlexibleContexts | ||
:set -XFlexibleInstances | ||
:set -XUndecidableInstances | ||
data A | ||
data B | ||
data C | ||
:{ | ||
data ABorC t where | ||
Foo :: Int -> ABorC A | ||
Bar :: Bool -> ABorC A | ||
Baz :: Char -> ABorC B | ||
Quz :: ABorC B | ||
Yud :: String -> ABorC C | ||
Myp :: Double -> ABorC C | ||
:} | ||
data HTrue | ||
data HFalse | ||
|
||
class TypeEq x y b | x y -> b | ||
instance (HTrue ~ b) => TypeEq x x b | ||
instance (HFalse ~ b) => TypeEq x y b | ||
|
||
type family Or a b | ||
type instance Or HTrue HTrue = HTrue | ||
type instance Or HTrue HFalse = HTrue | ||
type instance Or HFalse HTrue = HTrue | ||
type instance Or HFalse HFalse = HFalse | ||
|
||
let f :: (Or a c ~ HTrue, TypeEq t A a, TypeEq t C c) => ABorC t -> Int ; f x = 1 | ||
f $ Foo 1 | ||
f $ Bar True | ||
f $ Baz 'a' | ||
f $ Quz | ||
f $ Yud "a" | ||
f $ Myp 4.3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
|
||
<interactive>:38:1: | ||
Couldn't match type `HFalse' with `HTrue' | ||
In the expression: f | ||
In the expression: f $ Baz 'a' | ||
In an equation for `it': it = f $ Baz 'a' | ||
|
||
<interactive>:39:1: | ||
Couldn't match type `HFalse' with `HTrue' | ||
In the expression: f | ||
In the expression: f $ Quz | ||
In an equation for `it': it = f $ Quz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
1 | ||
1 | ||
1 | ||
1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--Testing proper error message for multiple declarations (a previous bug) | ||
data Foo = A | B | ||
data Foo = A | A | ||
data Foo = A | B | ||
data Foo = A | A |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
|
||
<interactive>:4:16: | ||
Multiple declarations of `A' | ||
Declared at: <interactive>:4:12 | ||
<interactive>:4:16 | ||
|
||
<interactive>:6:16: | ||
Multiple declarations of `A' | ||
Declared at: <interactive>:6:12 | ||
<interactive>:6:16 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--Testing RecordWildCards (a previous bug) | ||
data C = C {a :: Integer, b :: Integer, c :: Integer, d :: Integer} deriving Show | ||
let myc = C 1 2 3 4 | ||
:set -XFlexibleInstances | ||
instance Show (C -> Integer) where ; show a = "C -> field " ++ (show $ a myc) | ||
(a,b,c,d) | ||
:set -XRecordWildCards | ||
let C{..} = myc | ||
(a,b,c,d) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
(C -> field 1,C -> field 2,C -> field 3,C -> field 4) | ||
(1,2,3,4) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--Testing for proper name printing in complex error messages (a previous bug) | ||
:set -XTypeFamilies | ||
:set -XFlexibleInstances | ||
class Listable t where ; type ListableElem t :: * ; asList :: t -> [ListableElem t] | ||
instance Listable (a,a) where ; asList (a,b) = [a,b] | ||
instance Listable (a,a) where ; type ListableElem (a,a) = a ; asList (a,b) = [a,b] | ||
asList ("as","df") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
|
||
<interactive>:6:51: | ||
Couldn't match type `a' with `ListableElem (a, a)' | ||
`a' is a rigid type variable bound by | ||
the instance declaration at <interactive>:6:20 | ||
In the expression: b | ||
In the expression: [a, b] | ||
In an equation for `asList': asList (a, b) = [a, b] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
["as","df"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
--Testing complex type and constructor shadowing | ||
data T = A | B | ||
type T' = T | ||
let b = B :: T' | ||
data T = B | C | ||
let c = C :: T' | ||
let c = C | ||
data T = C | D | ||
let d = D | ||
:i T | ||
:i T' | ||
:i A | ||
:i B | ||
:i C | ||
:i D | ||
:i b | ||
:i c | ||
:i d |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
|
||
<interactive>:7:9: | ||
Couldn't match expected type `T'' with actual type `T' | ||
In the expression: C :: T' | ||
In an equation for `c': c = C :: T' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
data T = C | D -- Defined at <interactive>:0:10 | ||
type T' = :Interactive.T -- Defined at <interactive>:0:6-7 | ||
data :Interactive.T = A | ... -- Defined at <interactive>:0:10 | ||
data :Interactive.T = B | ... -- Defined at <interactive>:0:12 | ||
data T = C | ... -- Defined at <interactive>:0:14 | ||
data T = ... | D -- Defined at <interactive>:0:18 | ||
b :: T' -- Defined at <interactive>:0:5 | ||
c :: :Interactive.T -- Defined at <interactive>:0:5 | ||
d :: T -- Defined at <interactive>:0:5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--Testing data type and constructor shadowing with functions | ||
data Planet = Mercury | Venus | Earth | ||
let pn Mercury = "M" ; pn Venus = "V" ; pn Earth = "E" | ||
pn Mercury | ||
data Planet = Mercury | Venus | Mars | ||
pn Mercury | ||
pn Venus | ||
pn Mars | ||
pn Earth | ||
let pn Mercury = "M" ; pn Venus = "V" ; pn Earth = "E" ; pn Mars = "M" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
|
||
<interactive>:7:4: | ||
Couldn't match expected type `main::Interactive.Planet' | ||
with actual type `Planet' | ||
In the first argument of `pn', namely `Mercury' | ||
In the expression: pn Mercury | ||
In an equation for `it': it = pn Mercury | ||
|
||
<interactive>:8:4: | ||
Couldn't match expected type `main::Interactive.Planet' | ||
with actual type `Planet' | ||
In the first argument of `pn', namely `Venus' | ||
In the expression: pn Venus | ||
In an equation for `it': it = pn Venus | ||
|
||
<interactive>:9:4: | ||
Couldn't match expected type `main::Interactive.Planet' | ||
with actual type `Planet' | ||
In the first argument of `pn', namely `Mars' | ||
In the expression: pn Mars | ||
In an equation for `it': it = pn Mars | ||
|
||
<interactive>:11:44: | ||
Couldn't match expected type `Planet' | ||
with actual type `main::Interactive.Planet' | ||
In the pattern: Earth | ||
In an equation for `pn': pn Earth = "E" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
"M" | ||
"E" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--Testing deriving in the presence of shadowing | ||
data Planet = Mercury | Venus | Earth deriving Eq | ||
let mercury = Mercury | ||
Venus == Earth | ||
data Planet = Mercury | Venus deriving Eq | ||
Mercury == Mercury | ||
mercury == Mercury | ||
Mercury == Venus | ||
Venus == Earth | ||
Earth == Earth |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
|
||
<interactive>:8:12: | ||
Couldn't match expected type `main::Interactive.Planet' | ||
with actual type `Planet' | ||
In the second argument of `(==)', namely `Mercury' | ||
In the expression: mercury == Mercury | ||
In an equation for `it': it = mercury == Mercury | ||
|
||
<interactive>:10:10: | ||
Couldn't match expected type `Planet' | ||
with actual type `main::Interactive.Planet' | ||
In the second argument of `(==)', namely `Earth' | ||
In the expression: Venus == Earth | ||
In an equation for `it': it = Venus == Earth |
Oops, something went wrong.