Commit d2946abb authored by simonpj's avatar simonpj
Browse files

[project @ 2001-08-22 14:11:33 by simonpj]

Add tcrun015
parent 8724376d
......@@ -22,3 +22,4 @@ test "tcrun011" { vtr("", "", "") }
test "tcrun012" { vtr("", "", "") }
test "tcrun013" { vtr("", "", "") }
test "tcrun014" { vtr("", "", "") }
test "tcrun015" { vtr("-O", "", "") }
-- !!! Newtypes
-- A variation of tc014 that Sigbjorn said failed
module Main where
data Expr a b = One a | Many [b]
newtype Pat a = InP (Expr a (Pat a), Int)
newtype PExpr a = InPE (Expr a (PExpr a), Int)
plus1 x@(InPE (_, loc)) = InPE (Many [x], loc)
one x l = InPE (One (plus1 x), l)
outP (InP x) = x
getPatNames p
= case outP p of
(One n, _) -> [n]
(Many ps, _) -> concatMap getPatNames ps
main = print (take 10 (map getPatNames (repeat (InP (One "n", 1)))))
[["n"],["n"],["n"],["n"],["n"],["n"],["n"],["n"],["n"],["n"]]
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