1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | import Control.Monad data MyType a = MyType a instance Monad MyType where return f = undefined f >>= g = undefined instance MonadPlus MyType where mzero = MyType (0 :: Int) mplus = undefined main = do let foo = mzero :: MyType Int print 4 |
aW1wb3J0IENvbnRyb2wuTW9uYWQKCmRhdGEgTXlUeXBlIGEgPSBNeVR5cGUgYQoKaW5zdGFuY2UgTW9uYWQgTXlUeXBlIHdoZXJlCiAgIHJldHVybiBmID0gdW5kZWZpbmVkCiAgIGYgPj49IGcgPSB1bmRlZmluZWQKCmluc3RhbmNlIE1vbmFkUGx1cyBNeVR5cGUgd2hlcmUKICAgbXplcm8gPSBNeVR5cGUgKDAgOjogSW50KQogICBtcGx1cyA9IHVuZGVmaW5lZAoKbWFpbiA9IGRvCiAgbGV0IGZvbyA9IG16ZXJvIDo6IE15VHlwZSBJbnQKICBwcmludCA0
[1 of 1] Compiling Main ( prog.hs, prog.o )
prog.hs:10:19:
Couldn't match expected type `a' against inferred type `Int'
`a' is a rigid type variable bound by
the type signature for `mzero' at <no location info>
In the first argument of `MyType', namely `(0 :: Int)'
In the expression: MyType (0 :: Int)
In the definition of `mzero': mzero = MyType (0 :: Int)
-
result: Compilation error (maybe you wish to see an example for Haskell)


