summaryrefslogtreecommitdiff
path: root/testsuite/tests/typecheck/should_fail
diff options
context:
space:
mode:
authorFacundo Domínguez <facundo.dominguez@tweag.io>2014-12-09 18:10:18 -0600
committerAustin Seipp <austin@well-typed.com>2014-12-09 19:59:27 -0600
commitfc45f32491313d2a44e72d8d59cdf95b1660189d (patch)
tree853de68ce9feca6a61d2b540ef13fc03162740de /testsuite/tests/typecheck/should_fail
parente5974f8f53de4c97cfaad228eedfca8b31b53887 (diff)
downloadhaskell-fc45f32491313d2a44e72d8d59cdf95b1660189d.tar.gz
Implement -XStaticValues
Summary: As proposed in [1], this extension introduces a new syntactic form `static e`, where `e :: a` can be any closed expression. The static form produces a value of type `StaticPtr a`, which works as a reference that programs can "dereference" to get the value of `e` back. References are like `Ptr`s, except that they are stable across invocations of a program. The relevant wiki pages are [2, 3], which describe the motivation/ideas and implementation plan respectively. [1] Jeff Epstein, Andrew P. Black, and Simon Peyton-Jones. Towards Haskell in the cloud. SIGPLAN Not., 46(12):118–129, September 2011. ISSN 0362-1340. [2] https://ghc.haskell.org/trac/ghc/wiki/StaticPointers [3] https://ghc.haskell.org/trac/ghc/wiki/StaticPointers/ImplementationPlan Authored-by: Facundo Domínguez <facundo.dominguez@tweag.io> Authored-by: Mathieu Boespflug <m@tweag.io> Authored-by: Alexander Vershilov <alexander.vershilov@tweag.io> Test Plan: `./validate` Reviewers: hvr, simonmar, simonpj, austin Reviewed By: simonpj, austin Subscribers: qnikst, bgamari, mboes, carter, thomie, goldfire Differential Revision: https://phabricator.haskell.org/D550 GHC Trac Issues: #7015
Diffstat (limited to 'testsuite/tests/typecheck/should_fail')
-rw-r--r--testsuite/tests/typecheck/should_fail/TcStaticPointersFail01.hs11
-rw-r--r--testsuite/tests/typecheck/should_fail/TcStaticPointersFail01.stderr6
-rw-r--r--testsuite/tests/typecheck/should_fail/TcStaticPointersFail02.hs12
-rw-r--r--testsuite/tests/typecheck/should_fail/TcStaticPointersFail02.stderr14
-rw-r--r--testsuite/tests/typecheck/should_fail/TcStaticPointersFail03.hs9
-rw-r--r--testsuite/tests/typecheck/should_fail/TcStaticPointersFail03.stderr6
-rw-r--r--testsuite/tests/typecheck/should_fail/all.T6
7 files changed, 64 insertions, 0 deletions
diff --git a/testsuite/tests/typecheck/should_fail/TcStaticPointersFail01.hs b/testsuite/tests/typecheck/should_fail/TcStaticPointersFail01.hs
new file mode 100644
index 0000000000..7221b7369b
--- /dev/null
+++ b/testsuite/tests/typecheck/should_fail/TcStaticPointersFail01.hs
@@ -0,0 +1,11 @@
+{-# LANGUAGE StaticPointers #-}
+
+module StaticPointersFail01 where
+
+import GHC.StaticPtr
+
+f0 :: StaticPtr Int
+f0 = static g
+
+g :: Int -> Int
+g = id
diff --git a/testsuite/tests/typecheck/should_fail/TcStaticPointersFail01.stderr b/testsuite/tests/typecheck/should_fail/TcStaticPointersFail01.stderr
new file mode 100644
index 0000000000..e41ec7443d
--- /dev/null
+++ b/testsuite/tests/typecheck/should_fail/TcStaticPointersFail01.stderr
@@ -0,0 +1,6 @@
+
+TcStaticPointersFail01.hs:8:13:
+ Couldn't match expected type ‘Int’ with actual type ‘Int -> Int’
+ Probable cause: ‘g’ is applied to too few arguments
+ In the body of a static form: g
+ In the expression: static g
diff --git a/testsuite/tests/typecheck/should_fail/TcStaticPointersFail02.hs b/testsuite/tests/typecheck/should_fail/TcStaticPointersFail02.hs
new file mode 100644
index 0000000000..3b4d0ff661
--- /dev/null
+++ b/testsuite/tests/typecheck/should_fail/TcStaticPointersFail02.hs
@@ -0,0 +1,12 @@
+{-# LANGUAGE StaticPointers #-}
+{-# LANGUAGE ImpredicativeTypes #-}
+
+module StaticPointersFail02 where
+
+import GHC.StaticPtr
+
+f1 :: StaticPtr ((forall a . a -> a) -> b)
+f1 = static (undefined :: (forall a . a -> a) -> b)
+
+f2 :: StaticPtr (Monad m => a -> m a)
+f2 = static return
diff --git a/testsuite/tests/typecheck/should_fail/TcStaticPointersFail02.stderr b/testsuite/tests/typecheck/should_fail/TcStaticPointersFail02.stderr
new file mode 100644
index 0000000000..f11ec28f18
--- /dev/null
+++ b/testsuite/tests/typecheck/should_fail/TcStaticPointersFail02.stderr
@@ -0,0 +1,14 @@
+
+TcStaticPointersFail02.hs:9:6:
+ No instance for (Data.Typeable.Internal.Typeable b)
+ arising from a static form
+ In the expression: static (undefined :: (forall a. a -> a) -> b)
+ In an equation for ‘f1’:
+ f1 = static (undefined :: (forall a. a -> a) -> b)
+
+TcStaticPointersFail02.hs:12:6:
+ No instance for (Data.Typeable.Internal.Typeable Monad)
+ (maybe you haven't applied enough arguments to a function?)
+ arising from a static form
+ In the expression: static return
+ In an equation for ‘f2’: f2 = static return
diff --git a/testsuite/tests/typecheck/should_fail/TcStaticPointersFail03.hs b/testsuite/tests/typecheck/should_fail/TcStaticPointersFail03.hs
new file mode 100644
index 0000000000..58e06ee1d8
--- /dev/null
+++ b/testsuite/tests/typecheck/should_fail/TcStaticPointersFail03.hs
@@ -0,0 +1,9 @@
+{-# LANGUAGE StaticPointers #-}
+
+module StaticPointersFail03 where
+
+import GHC.StaticPtr
+import Data.Typeable
+
+f1 :: (Typeable a, Typeable m, Monad m) => a -> m a
+f1 = deRefStaticPtr (static return)
diff --git a/testsuite/tests/typecheck/should_fail/TcStaticPointersFail03.stderr b/testsuite/tests/typecheck/should_fail/TcStaticPointersFail03.stderr
new file mode 100644
index 0000000000..03a01df842
--- /dev/null
+++ b/testsuite/tests/typecheck/should_fail/TcStaticPointersFail03.stderr
@@ -0,0 +1,6 @@
+
+TcStaticPointersFail03.hs:9:29:
+ No instance for (Monad m) arising from a use of ‘return’
+ In the body of a static form: return
+ In the first argument of ‘deRefStaticPtr’, namely ‘(static return)’
+ In the expression: deRefStaticPtr (static return)
diff --git a/testsuite/tests/typecheck/should_fail/all.T b/testsuite/tests/typecheck/should_fail/all.T
index d3c8941c65..1546b3ae8c 100644
--- a/testsuite/tests/typecheck/should_fail/all.T
+++ b/testsuite/tests/typecheck/should_fail/all.T
@@ -328,6 +328,12 @@ test('ContextStack2', normal, compile_fail, ['-ftype-function-depth=10'])
test('T8570', extra_clean(['T85570a.o', 'T8570a.hi','T85570b.o', 'T8570b.hi']),
multimod_compile_fail, ['T8570', '-v0'])
test('T8603', normal, compile_fail, [''])
+test('TcStaticPointersFail01',
+ when(compiler_lt('ghc', '7.9'), skip), compile_fail, [''])
+test('TcStaticPointersFail02',
+ when(compiler_lt('ghc', '7.9'), skip), compile_fail, [''])
+test('TcStaticPointersFail03',
+ when(compiler_lt('ghc', '7.9'), skip), compile_fail, [''])
test('T8806', normal, compile_fail, [''])
test('T8912', normal, compile_fail, [''])
test('T9033', normal, compile_fail, [''])