-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'haskellfoundation:main' into dylan-thinnes/generate-mac…
…hine-readable-spec
- Loading branch information
Showing
19 changed files
with
257 additions
and
75 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module A where | ||
|
||
class Calculator a where | ||
add :: a -> a -> a | ||
multiply :: a -> a -> a | ||
|
||
instance Calculator Int where | ||
add a b = a + b | ||
multiply a b = a * b |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module A where | ||
|
||
class Calculator a where | ||
add :: a -> a -> a | ||
multiply :: a -> a -> a | ||
|
||
instance Calculator Int where | ||
add a b = a + b |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
title: No explicit implementation for method instance | ||
--- | ||
|
||
## Error Message | ||
|
||
``` | ||
A.hs:7:10: warning: [GHC-06201] [-Wmissing-methods] | ||
• No explicit implementation for | ||
‘multiply’ | ||
• In the instance declaration for ‘Calculator Int’ | ||
| | ||
7 | instance Calculator Int where | ||
``` | ||
|
||
## Explanation | ||
|
||
The type class `Calculator` requires you to implement two methods: `add` and `multiply`. | ||
However, the example instance `instance Calculator Int` only implements the method `add` and not `multiply` | ||
To fix this, implement the method `multiply`! |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module A where | ||
|
||
data Box t = SomeBox t | ||
|
||
instance Functor Box where | ||
fmap f (SomeBox a) = SomeBox (f a) | ||
|
||
instance Applicative Box where | ||
pure a = SomeBox a | ||
SomeBox f <*> SomeBox a = SomeBox (f a) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module A where | ||
|
||
data Box t = SomeBox t | ||
|
||
instance Functor Box where | ||
fmap f (SomeBox a) = SomeBox (f a) | ||
|
||
instance Applicative Box where | ||
pure a = SomeBox a |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
--- | ||
title: No explicit implementation for method instance 2 | ||
--- | ||
|
||
## Error Message | ||
|
||
``` | ||
A.hs:8:10: warning: [GHC-06201] [-Wmissing-methods] | ||
• No explicit implementation for | ||
either ‘<*>’ or ‘liftA2’ | ||
• In the instance declaration for ‘Applicative Box’ | ||
| | ||
8 | instance Applicative Box where | ||
| ^^^^^^^^^^^^^^^ | ||
``` | ||
|
||
## Explanation | ||
|
||
The type class `Applicative` requires you to implement at least two methods: | ||
|
||
* `pure`, and | ||
* `liftA2` or `multiply` (can also be both). | ||
|
||
Such `or` constraints can be expressed via the [`{-# MINIMAL #-}`](https://downloads.haskell.org/ghc/latest/docs/users_guide/exts/pragmas.html#minimal-pragma) pragma. | ||
|
||
To fix this, either implement the method `liftA2` or `<*>`. For this example, we implemented `<*>`, but either or both is fine, too. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
title: Missing method in type class instance | ||
summary: A required method is missing from the instance declaration. | ||
severity: warning | ||
flag: -Wmissing-methods | ||
introduced: 9.6.1 | ||
--- | ||
|
||
This warning means that a type class instance is missing some required method implementations. |
5 changes: 5 additions & 0 deletions
5
message-index/messages/GHC-87139/illegalDerivingStrategy/after/IllegalDerivingStrategy.hs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{-# LANGUAGE DerivingStrategies #-} | ||
module IllegalDerivingStrategy where | ||
|
||
newtype Year = MkYear Int | ||
deriving newtype Show |
4 changes: 4 additions & 0 deletions
4
message-index/messages/GHC-87139/illegalDerivingStrategy/before/IllegalDerivingStrategy.hs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module IllegalDerivingStrategy where | ||
|
||
newtype Year = MkYear Int | ||
deriving newtype Show |
Oops, something went wrong.