This commit is contained in:
John Gatward committed 2026-10-04 15:24:17 +01:00
1 parent d0f27f276b
commit d6f54d4ec2
103 files changed
+3663 -3779

No files matched your search

+5 -8
View File
@@ -1,6 +1,6 @@
# Functor
Parsing an expression in parenthesis:
Parsing an expression in parentheses:
```haskell
parseP :: Parser AST
@@ -22,9 +22,9 @@ Before we write this sort of code, we need to understand `type classes` (especia
| String | Functor |
| | Monad |
**Eq**: typeclass equality; A type can only be typeclass equality if two like types can be compared
**Eq**: type class for equality; a type can only be in this type class if two values of that type can be compared
A type can be a *member* (instance) of a type class, meaning that if has the properties/functions that the class requires
A type can be a *member* (instance) of a type class, meaning that it has the properties/functions that the class requires
e.g. `Bool` is an instance of `Eq` and `Show`
@@ -61,7 +61,7 @@ newtype Parser a = P (String -> [a, String])
**Parser AST** is a type
Functor is a typeclass of which `parser` is an instance
Functor is a type class of which `parser` is an instance
##### Functor
@@ -95,7 +95,4 @@ fmap id = id -- identity
fmap (f . g) = fmap f . fmap g
```
Haskell doesn't enforce these rules however it is convention.
Haskell doesn't enforce these rules; however, following them is convention.