2025-01-15 21:34:22 +01:00
|
|
|
```haskell
|
|
|
|
add :: (Int -> Int) -> Int
|
|
|
|
add x y = x+y
|
2025-01-15 21:52:02 +01:00
|
|
|
|
|
|
|
instance Eq Bool where
|
|
|
|
True == True = True
|
|
|
|
False == False = True
|
|
|
|
_ == _ = False
|
|
|
|
|
|
|
|
instance (Eq a, Eq b) => Eq (a, b) where
|
|
|
|
(x1, y1) == (x2, y2) = x1 == x2 && y1 == y2
|
|
|
|
|
|
|
|
-- A value that exists
|
|
|
|
myValue :: Maybe Int
|
|
|
|
myValue = Just 42
|
|
|
|
|
|
|
|
-- A value that doesn't exist
|
|
|
|
noValue :: Maybe Int
|
|
|
|
noValue = Nothing
|
|
|
|
|
|
|
|
|
2025-01-15 21:34:22 +01:00
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
```python
|
|
|
|
|
|
|
|
class Number:
|
|
|
|
# Some implementation
|
|
|
|
|
|
|
|
class Float(Number):
|
|
|
|
# Some implentation
|
|
|
|
|
|
|
|
class Integer(Number):
|
|
|
|
# Some implementation
|
|
|
|
|
|
|
|
|
|
|
|
def add(numA:Number, numB:Number) -> Number:
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
```python
|
|
|
|
|
|
|
|
class MyClass:
|
|
|
|
def __eq__(self):
|
|
|
|
# MyClass :: Eq
|
|
|
|
def __str__(self)
|
|
|
|
# MyClass :: Show
|
|
|
|
def __
|
|
|
|
```
|