Skip to content

Instantly share code, notes, and snippets.

@joneshf
Last active August 29, 2015 13:57
Show Gist options
  • Save joneshf/9375359 to your computer and use it in GitHub Desktop.
Save joneshf/9375359 to your computer and use it in GitHub Desktop.
>> Error in declaration filter:
>> Error checking type of term \_1 -> \_2 -> case _1 _2 of { (p, f) -> Data.Foldable.foldMap(\x -> p(x) ? Prelude.pure(x) : Data.Monoid.mempty)(f) } against type forall f. forall a. (Prelude.Applicative (f),Data.Foldable.Foldable (f),Data.Monoid.Monoid (f a)) => (a -> Prim.Boolean) -> f a -> f a:
>> Error checking type of term \_1 -> \_2 -> case _1 _2 of { (p, f) -> Data.Foldable.foldMap(\x -> p(x) ? Prelude.pure(x) : Data.Monoid.mempty)(f) } against type forall a. (Prelude.Applicative (s1840),Data.Foldable.Foldable (s1840),Data.Monoid.Monoid (s1840 a)) => (a -> Prim.Boolean) -> s1840 a -> s1840 a:
>> Error checking type of term \_1 -> \_2 -> case _1 _2 of { (p, f) -> Data.Foldable.foldMap(\x -> p(x) ? Prelude.pure(x) : Data.Monoid.mempty)(f) } against type (Prelude.Applicative (s1840),Data.Foldable.Foldable (s1840),Data.Monoid.Monoid (s1840 s1842)) => (s1842 -> Prim.Boolean) -> s1840 s1842 -> s1840 s1842:
>> Error checking type of term \_1 -> \_2 -> case _1 _2 of { (p, f) -> Data.Foldable.foldMap(\x -> p(x) ? Prelude.pure(x) : Data.Monoid.mempty)(f) } against type (s1842 -> Prim.Boolean) -> s1840 s1842 -> s1840 s1842:
>> Error checking type of term \_2 -> case _1 _2 of { (p, f) -> Data.Foldable.foldMap(\x -> p(x) ? Prelude.pure(x) : Data.Monoid.mempty)(f) } against type s1840 s1842 -> s1840 s1842:
>> Error checking type of term case _1 _2 of { (p, f) -> Data.Foldable.foldMap(\x -> p(x) ? Prelude.pure(x) : Data.Monoid.mempty)(f) } against type s1840 s1842:
>> Error checking type of term Data.Foldable.foldMap(\x -> p(x) ? Prelude.pure(x) : Data.Monoid.mempty)(f) against type s1840 s1842:
>> Error inferring type of term Data.Foldable.foldMap(\x -> p(x) ? Prelude.pure(x) : Data.Monoid.mempty):
>> Error applying function of type forall f. (Data.Foldable.Foldable (f)) => forall m. forall a. (Data.Monoid.Monoid (m)) => (a -> m) -> f a -> m to argument \x -> p(x) ? Prelude.pure(x) : Data.Monoid.mempty:
>> Error applying function of type (Data.Foldable.Foldable (u1846)) => forall m. forall a. (Data.Monoid.Monoid (m)) => (a -> m) -> u1846 a -> m to argument \x -> p(x) ? Prelude.pure(x) : Data.Monoid.mempty:
>> Error applying function of type forall a. (Data.Monoid.Monoid (u1847)) => (a -> u1847) -> u1846 a -> u1847 to argument \x -> p(x) ? Prelude.pure(x) : Data.Monoid.mempty:
>> Error applying function of type (Data.Monoid.Monoid (u1847)) => (u1848 -> u1847) -> u1846 u1848 -> u1847 to argument \x -> p(x) ? Prelude.pure(x) : Data.Monoid.mempty:
>> Error checking type of term \x -> p(x) ? Prelude.pure(x) : Data.Monoid.mempty against type u1848 -> u1847:
>> Error checking type of term p(x) ? Prelude.pure(x) : Data.Monoid.mempty against type u1847:
>> Error inferring type of term p(x) ? Prelude.pure(x) : Data.Monoid.mempty:
>> Error unifying type u1851 u1852 with type forall m. (Data.Monoid.Monoid (m)) => m:
>> Error unifying type forall m. (Data.Monoid.Monoid (m)) => m with type u1851 u1852:
>> Error unifying type (Data.Monoid.Monoid (s1854)) => s1854 with type u1851 u1852:
>> Cannot unify (Data.Monoid.Monoid (s1854)) => s1854 with u1851 u1852.
module Data.Foldable where
import Prelude
import Data.Monoid
class Foldable f where
foldr :: forall a b. (a -> b -> b) -> b -> f a -> b
foldl :: forall a b. (b -> a -> b) -> b -> f a -> b
foldMap :: forall a m. (Monoid m) => (a -> m) -> f a -> m
filter :: forall a f. (Applicative f, Foldable f, Monoid (f a)) => (a -> Boolean) -> f a -> f a
filter p f = foldMap (\x -> if p x then pure x else mempty) f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment