blob: 751e9aa5bf41d5c5754b22dacfa2a22f5f4872da (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
-- !!! Newtypes
-- This one made ghc 5.01 (after newtype squashing) fall over
-- by generating Core code that contained a pattern match on
-- the InPE data constructor (which doesn't exist)
module Main where
data Expr e = One e | Many [e]
newtype PExpr a = InPE (Expr (PExpr a), Int)
one :: Int -> PExpr e -> PExpr e
one l x = InPE (One (plus1 x), l)
plus1 :: PExpr a -> PExpr a
plus1 x@(InPE (_, loc)) = InPE (Many [plus1 x], loc)
get :: PExpr e -> Int
get (InPE (_,l)) = l
main = print (get (plus1 (InPE (Many [], 0))))
|