Last active
January 7, 2018 13:54
-
-
Save HirotoShioi/26c6dd1072578878b45d9d12f0b15d4a to your computer and use it in GitHub Desktop.
Haskellにおける型クラス制約の役割 ref: https://qiita.com/HirotoShioi/items/5474119ba3682448c109
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
• No instance for (Num a) arising from a use of ‘+’ | |
Possible fix: | |
add (Num a) to the context of | |
the type signature for: | |
sum' :: forall a. [a] -> a | |
• In the expression: x + acc | |
In the first argument of ‘foldl1’, namely ‘(\ x acc -> x + acc)’ | |
In the expression: foldl1 (\ x acc -> x + acc) | |
| | |
5 | sum' = foldl1 (\x acc -> x + acc) | |
| |
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
*Main> sum' [1,2,3,4,5] | |
15 |
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
sum' :: (Num a) => [a] -> a | |
sum' = foldr1 (\x acc -> x + acc) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment