-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
38 changed files
with
297 additions
and
12 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
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 @@ | ||
{-# LANGUAGE LambdaCase #-} | ||
|
||
module Main where | ||
|
||
f = curry $ \case (Just x, Left y) -> Just (x, y) | ||
(Nothing, Right y) | y == 99 -> Just (0, "99") | ||
_ -> Nothing | ||
|
||
main = print $ [ f (Just 1) (Left "Y") == Just (1, "Y") | ||
, f (Just 1) (Right 99) == Nothing | ||
, f Nothing (Right 99) == Just (0, "99") | ||
, f Nothing (Right 9) == Nothing | ||
, f Nothing (Left "Y") == Nothing ] | ||
|
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 @@ | ||
[True,True,True,True,True] |
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,28 @@ | ||
{-# LANGUAGE MultiWayIf #-} | ||
|
||
module Main where | ||
|
||
import Data.List (isSuffixOf) | ||
import Control.Exception | ||
|
||
errMsg = "Non-exhaustive guards in multi-way if\n" | ||
table = [(1, "one"), (100, "hundred")] | ||
|
||
f t x = if | l <- length t, l > 2, l < 5 -> "length is 3 or 4" | ||
| Just y <- lookup x t -> y | ||
| False -> "impossible" | ||
| null t -> "empty" | ||
|
||
main = do | ||
print $ [ f table 1 == "one" | ||
, f table 100 == "hundred" | ||
, f [] 1 == "empty" | ||
, f [undefined, undefined, undefined] (undefined :: Bool) == | ||
"length is 3 or 4" | ||
, f ((0, "zero") : table) 100 == "length is 3 or 4" | ||
] | ||
r <- try $ evaluate $ f table 99 | ||
print $ case r of | ||
Left (PatternMatchFail s) | errMsg `isSuffixOf` s -> 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,2 @@ | ||
[True,True,True,True,True] | ||
True |
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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
{-# LANGUAGE TypeFamilies #-} | ||
|
||
module T7010 where | ||
|
||
type Vector = Serial Float | ||
data Serial v = Serial | ||
|
||
class MakeValueTuple a where | ||
type ValueTuple a :: * | ||
|
||
instance MakeValueTuple Float where | ||
type ValueTuple Float = IO Float | ||
|
||
instance (MakeValueTuple v) => MakeValueTuple (Serial v) where | ||
type ValueTuple (Serial v) = Serial (ValueTuple v) | ||
|
||
|
||
stereoFromMono :: (v, v) | ||
stereoFromMono = undefined | ||
|
||
processIO :: | ||
(MakeValueTuple a) => | ||
(ValueTuple a, ValueTuple a) -> | ||
(a, a) | ||
processIO = undefined | ||
|
||
|
||
phoneme :: (Vector, Vector) | ||
phoneme = processIO stereoFromMono | ||
|
||
|
||
withArgs :: | ||
(MakeValueTuple b) => | ||
(a, ValueTuple b) -> | ||
(a, b) | ||
withArgs = undefined | ||
|
||
plug :: | ||
(MakeValueTuple b) => | ||
(b, ValueTuple b) | ||
plug = undefined | ||
|
||
filterFormants :: (Float, Vector) | ||
filterFormants = withArgs plug |
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 @@ | ||
|
||
T7010.hs:44:27: | ||
Couldn't match type `Serial (ValueTuple Float)' with `IO Float' | ||
Expected type: (Float, ValueTuple Vector) | ||
Actual type: (Float, ValueTuple Float) | ||
In the first argument of `withArgs', namely `plug' | ||
In the expression: withArgs plug | ||
In an equation for `filterFormants': filterFormants = withArgs plug |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
module T7041 where | ||
|
||
gcdInt :: Int -> Int -> Int | ||
gcdInt a b = fromInteger (gcd (toInteger a) (toInteger 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
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,17 @@ | ||
|
||
{-# LANGUAGE MagicHash #-} | ||
|
||
module Main (main) where | ||
|
||
import GHC.Base | ||
import GHC.Integer | ||
|
||
main :: IO () | ||
main = case i of | ||
I# i# -> | ||
print (gcd (smallInteger i#) (smallInteger i#)) | ||
|
||
{-# NOINLINE i #-} | ||
i :: Int | ||
i = minBound | ||
|
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 @@ | ||
9223372036854775808 |
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 @@ | ||
{-# LANGUAGE LambdaCase #-} | ||
|
||
module ParserLambdaCase where | ||
|
||
f1 = \case "1" -> 1 | ||
f2 = \ {- comment1 {- comment2 -} -} case "1" -> 1; "2" -> 2 | ||
f3 = \ -- comment | ||
case "1" -> 1 | ||
"2" -> 2 | ||
f4 = \casex -> casex | ||
f5 = \ case { "1" -> 1; "2" -> 2 } | ||
|
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module ParserNoLambdaCase where | ||
|
||
f = \case "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,2 @@ | ||
|
||
ParserNoLambdaCase.hs:3:6: parse error on input `case' |
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 @@ | ||
module ParserNoMultiWayIf where | ||
|
||
x = 123 | ||
y = if | x < 0 -> -1 | ||
| x == 0 -> 0 | ||
| otherwise -> 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,3 @@ | ||
|
||
ParserNoMultiWayIf.hs:4:5: | ||
Multi-way if-expressions need -XMultiWayIf turned on |
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{-# LANGUAGE MultiWayIf #-} | ||
|
||
module Main where | ||
|
||
x = 10 | ||
x1 = if | x < 10 -> "< 10" | otherwise -> "" | ||
x2 = if | x < 10 -> "< 10" | ||
| otherwise -> "" | ||
x3 = if | x < 10 -> "< 10" | ||
| otherwise -> "" | ||
x4 = if | True -> "yes" | ||
x5 = if | True -> if | False -> 1 | True -> 2 | ||
|
||
main = print $ x5 == 2 | ||
|
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 @@ | ||
True |
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{-# LANGUAGE PolyKinds, TypeFamilies #-} | ||
|
||
module T7073 where | ||
|
||
class Foo a where | ||
type Bar a | ||
type Bar a = Int | ||
|
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{-# LANGUAGE LambdaCase #-} | ||
|
||
module TcLambdaCase where | ||
|
||
import Data.Bits ((.|.)) | ||
|
||
f1 :: (a -> a) -> (a -> a) | ||
f1 = \case x -> x | ||
|
||
f2 :: Num a => a -> a | ||
f2 = \case x -> x + x | ||
|
||
f3 :: Int -> (Int, Int) | ||
f3 = (\case y -> (y + y, y * y)) . (.|. 12) | ||
|
||
f4 = \case _ -> undefined | ||
|
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{-# LANGUAGE MultiParamTypeClasses #-} | ||
{-# LANGUAGE FunctionalDependencies #-} | ||
module T5978 where | ||
|
||
class C from to | from -> to where | ||
|
||
instance C Float Char where | ||
instance C Double Bool where | ||
|
||
|
||
polyFoo :: (C from to) => from | ||
polyFoo = undefined | ||
|
||
polyBar :: | ||
(C fromA toA, C fromB toB) => | ||
(toA -> toB) -> | ||
fromA -> fromB | ||
polyBar = undefined | ||
|
||
|
||
monoBar :: Double | ||
monoBar = polyBar id monoFoo | ||
|
||
monoFoo :: Float | ||
monoFoo = polyFoo | ||
|
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 @@ | ||
|
||
T5978.hs:22:11: | ||
Couldn't match type `Bool' with `Char' | ||
When using functional dependencies to combine | ||
C Double Bool, | ||
arising from the dependency `from -> to' | ||
in the instance declaration at T5978.hs:8:10 | ||
C Double Char, arising from a use of `polyBar' at T5978.hs:22:11-17 | ||
In the expression: polyBar id monoFoo | ||
In an equation for `monoBar': monoBar = polyBar id monoFoo |
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 @@ | ||
{-# LANGUAGE MultiWayIf #-} | ||
|
||
module TcMultiWayIfFail where | ||
|
||
x1 = if | True -> 1 :: Int | ||
| False -> "2" | ||
| otherwise -> [3 :: Int] | ||
|
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,16 @@ | ||
|
||
TcMultiWayIfFail.hs:6:24: | ||
Couldn't match expected type `Int' with actual type `[Char]' | ||
In the expression: "2" | ||
In the expression: | ||
if | True -> 1 :: Int | False -> "2" | otherwise -> [3 :: Int] | ||
In an equation for `x1': | ||
x1 = if | True -> 1 :: Int | False -> "2" | otherwise -> [3 :: Int] | ||
|
||
TcMultiWayIfFail.hs:7:24: | ||
Couldn't match expected type `Int' with actual type `[Int]' | ||
In the expression: [3 :: Int] | ||
In the expression: | ||
if | True -> 1 :: Int | False -> "2" | otherwise -> [3 :: Int] | ||
In an equation for `x1': | ||
x1 = if | True -> 1 :: Int | False -> "2" | otherwise -> [3 :: Int] |
Oops, something went wrong.