Plan 9 from Bell Labs’s /usr/web/sources/contrib/fernan/nhc98/tests/nhc-bugs/import/Main.hs

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


-- This trivial newtype causes a compiler crash in nhc98-1.18.  It is
-- only triggered when the import Control.Monad is present!

module Main (main) where
import Control.Monad (liftM2)
newtype A a = A a

main :: IO ()
main = return ()

-- It turns out that the type variable 'a' was being checked for
-- correctness as if it were a constructor, but if the constructor
-- did not exist there was silence.  Only when an actual constructor
-- (or in this case, class) shared the same internal identity number as
-- the variable, did the error become visible.

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.