Commit 16564aa3 authored by simonpj's avatar simonpj
Browse files

[project @ 2001-11-01 10:30:13 by simonpj]

Add test that killed 5.02
parent 7a9cd699
{-# OPTIONS -fglasgow-exts #-}
-- Helper for simpl009.hs (see comments there)
module Simpl009Help where
import Monad
newtype Parser s a
= Parser (forall res . (a -> [String] -> P s res) -> [String] -> P s res)
data P s res
= Symbol (s -> P s res)
| Fail [String] [String]
| Result res (P s res)
instance Monad (Parser s) where
return a = Parser (\fut -> fut a)
Parser f >>= k =
Parser (\fut -> f (\a -> let Parser g = k a in g fut))
fail s =
Parser (\fut exp -> Fail exp [s])
instance MonadPlus (Parser s) where
mzero =
Parser (\fut exp -> Fail exp [])
lookAhead :: Parser s s
lookAhead =
Parser (\fut exp -> Symbol (\c ->
feed c (fut c [])
))
where
feed c (Symbol sym) = sym c
feed c (Result res fut) = Result res (feed c fut)
feed c p@(Fail _ _) = p
......@@ -15,3 +15,7 @@ test "simpl006" { vtc("-package concurrent") }
test "simpl007" { vtc("") }
test "simpl008" { vtc("-fglasgow-exts") }
-- these two are really a multi-module test
test "Simpl009Help" { vtc("-O") }
test "simpl009" { vtc("-O") }
{-# OPTIONS -fglasgow-exts #-}
-- This one killed GHC 5.02 with a funResultTy panic
-- The reason was that the simplifier was doing a
-- case-of-case where the result had a polymorphic type.
-- This in turn showed up because of a newtype (now
-- transparent) with a forall inside it.
--
-- It's quite hard to tickle this one, hence the two-module setup.
module FormParse where
import Monad
import Simpl009Help
identifier :: Parser Char Char
identifier =
do c <- lookAhead
guard (c == 'a')
return c
Markdown is supported
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