-
-
Save phadej/7b95d1876dd085d28f49bf4ebf349663 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyNum a where | |
my_plus :: a -> a -> a | |
my_fromInteger :: Integer -> a | |
class MyNum a => MyIntegral a where | |
my_toInteger :: a -> Integer | |
my_fromIntegral :: (MyIntegral a, MyNum b) => a -> b | |
my_fromIntegral = my_fromInteger . my_toInteger | |
-- this is silly | |
plus :: (MyIntegral a, MyIntegral b) => a -> b -> a | |
plus a b = my_plus a (my_fromIntegral b) | |
plus2 a b = plus b (plus b a) -- reverse | |
result = plus2 1 2 | |
{- | |
• No instance for (MyIntegral b1) arising from a use of ‘plus2’ | |
• In the expression: plus2 1 2 | |
In an equation for ‘result’: result = plus2 1 2 | |
| | |
30 | result = plus2 1 2 | |
| ^^^^^^^^^ | |
bar.hs:30:16: error: | |
• Ambiguous type variable ‘b0’ arising from the literal ‘1’ | |
-} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment