Commit 6f14d73a authored by twhitehe@uwo.ca's avatar twhitehe@uwo.ca
Browse files

Differentiate between use of fail and failure of code (i.e., an exception is thrown)

parent 8ec7b43a
{-# OPTIONS_GHC -fth #-}
-- Test error message when the code in a splice
-- fails (e.g. with pattern match failure)
-- fails in an immediate fashion (e.g. with a
-- pattern match failure)
module ShouldCompile where
$( case reverse "no" of
[] -> return []
)
{-# OPTIONS -fth #-}
-- A (head []) failure within a TH splice
-- This one generates an exception in the TH
-- code which should be caught in a civilised way
-- Test error message when the code in a splice
-- fails in a lazy fashion (e.g. a (head [])
-- thunk is embedded in the returned structure).
module TH where
$( do { ds <- [d| |]
; return (tail ds) }
)
TH_exn.hs:1:0:
Exception when trying to run compile-time code:
Exception when trying to interpret result of compile-time code:
Prelude.tail: empty list
Code: let
>>= = (>>=) @ Language.Haskell.TH.Syntax.Q $dMonad
......
......@@ -65,10 +65,10 @@ test('TH_where', normal, compile_and_run, [''])
test('TH_spliceInst', normal, compile, [''])
test('TH_fail', normal, compile_fail, [''])
test('TH_exn1', normal, compile_fail, [''])
test('TH_dupdecl', normal, compile_fail, [''])
test('TH_exn', normal, compile_fail, [''])
test('TH_exn2', normal, compile_fail, [''])
test('TH_recover', normal, compile_and_run, [''])
test('TH_dataD1', normal, compile_fail, ['-v0'])
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment