2 Date: Wed, 3 Sep 1997 10:25:35 +0200 (MET DST)
3 From: Jon Mountjoy <jon@wins.uva.nl>
7 The following program (rather condensed as it comes from something
8 much larger), crashes the compiler. I am using ghc-2.05 on a Solaris
9 box, with one or two patches(including the WwLib one which Simon gave
10 me, but this error occured before applying this patch).
12 It seems to be some rather subtle dependency problem. Compiling with
13 -O solves the problem, compiling with ghc -c Foo.lhs should highlight
14 it. The error message is appended below the file. What are the new
15 "discarding polymorphic case" warnings about?
17 If you change any line in reallyFlatten, the program compiles fine.
18 Likewise if you change the type of LinearCode to Int!
29 > reallyFlatten :: Int -> Int -> Interpreter ()
34 > setIStatus (IFlattened f f)
37 > goo :: Int -> LinearCode
38 > goo = \x -> listArray (0,1) []
40 %---------------------------------------------------------------------
42 > type LinearCode = Array Int Int
44 > data InterpStatus = IFlattened !LinearCode !LinearCode
45 > data SM = SM { interpStatus :: InterpStatus }
46 > initialState = SM { interpStatus = IFlattened undefined undefined }
48 > newtype Interpreter a = RepInterp ((SM,Int) -> IO (Error ((SM,Int),a)))
49 > getRepInterp (RepInterp a ) = a
51 > instance Functor Interpreter where
52 > map f (RepInterp intp )
53 > = RepInterp (\s -> case intp s of
56 > Error mes -> return $ Error mes
57 > Ok (s',a') -> return $ Ok (s',f a'))
59 > instance Monad Interpreter where
60 > return x = RepInterp (\s -> return (Ok (s,x)))
61 > (RepInterp intp) >>= g
62 > = RepInterp(\s -> case intp s of
65 > Error mes -> return $ Error mes
66 > Ok (s',x') -> getRepInterp (g x') s' )
68 > instance OutputMonad Interpreter where
69 > out s = RepInterp (\st -> putStr s >>
70 > return (Ok (st,())))
72 > updateSM :: (SM -> SM) -> Interpreter SM
73 > updateSM f = RepInterp (\s@(sm,ty) -> return $ Ok ((f sm,ty), sm))
75 > setIStatus :: InterpStatus -> Interpreter InterpStatus
76 > setIStatus is = updateSM (\sm -> sm {interpStatus = is}) >>=
79 > data Error a = Ok a | Error String
81 > class Monad m => OutputMonad m where
82 > out :: String -> m ()
83 > instance OutputMonad IO where
84 > out s = catch (putStr s) (\_ -> fail $userError "Oh MY")