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

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


{-
The program below compiles with nhc, but doesn't if the commented
line is uncommented. It doesn't compile with tracing at all.
It compiles with ghc though, with both versions: with and without
the typing in the comment...
-}
--------------------------------------------------------------------
data Test = Test Int

--default (Integer,Double,Test)

class TestClass a where
  method :: a -> Int

instance TestClass Test where
  method (Test i) = 2*i

-- f :: TestClass a => a -> Int
f :: TestClass a => a -> Int
f t = if (method t)==0 then (g t) else 3*(method t)

g :: TestClass b => b -> Int
g t = 4*(f t)

main = putStrLn (show (g (Test 2)))


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.