Created
March 25, 2016 11:55
-
-
Save jakab922/67174b1a2542e73f5104 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
{- | |
Based on | |
- https://www.schoolofhaskell.com/school/to-infinity-and-beyond/pick-of-the-week/guide-to-ghc-extensions/list-and-comprehension-extensions | |
-} | |
{-# LANGUAGE ParallelListComp, TransformListComp #-} | |
f :: (Num a, Ord a) => [a] -> [a] -> [(a, a)] | |
f xs ys = [(x, y) | x <- xs, | |
then (filter (\z -> z > 10)) | |
| y <- ys, | |
then reverse] | |
main = print $ f [1..5] [11..15] | |
{- | |
runhaskell transform.hs produces the following errors: | |
transform.hs:10:43: | |
Could not deduce (Ord a1) arising from a use of ‘>’ | |
from the context (Num a, Ord a) | |
bound by the type signature for | |
f :: (Num a, Ord a) => [a] -> [a] -> [(a, a)] | |
at transform.hs:8:6-45 | |
Possible fix: | |
add (Ord a1) to the context of | |
a type expected by the context: [a1] -> [a1] | |
In the expression: z > 10 | |
In the first argument of ‘filter’, namely ‘(\ z -> z > 10)’ | |
In the expression: (filter (\ z -> z > 10)) | |
transform.hs:10:45: | |
Could not deduce (Num a1) arising from the literal ‘10’ | |
from the context (Num a, Ord a) | |
bound by the type signature for | |
f :: (Num a, Ord a) => [a] -> [a] -> [(a, a)] | |
at transform.hs:8:6-45 | |
Possible fix: | |
add (Num a1) to the context of | |
a type expected by the context: [a1] -> [a1] | |
In the second argument of ‘(>)’, namely ‘10’ | |
In the expression: z > 10 | |
In the first argument of ‘filter’, namely ‘(\ z -> z > 10)’ | |
-} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment