Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {-# Language
- RankNTypes
- ,FunctionalDependencies
- ,FlexibleContexts
- ,ScopedTypeVariables
- #-}
- module Traversable where
- import Traversable_r
- import Data.Monoid (Endo(..))
- import Endo1
- import Data.Functor.Identity
- import Control.Applicative (Const(..))
- import Data.Coerce
- import Data.Functor.Apply (Apply(..))
- import Data.Maybe (fromJust)
- ----
- -- Functor
- class Functor_r Identity f => Functor' f
- fmap' :: Functor' f => (a -> b) -> f a -> f b
- fmap' f = fmap_r (Identity . f . runIdentity)
- ----
- -- Foldable1
- class Foldable1_r Identity t => Foldable1' t
- foldr1' :: Foldable1' t => (Identity a -> Maybe b -> b) -> t a -> b
- foldr1' = foldr1_r
- foldMap1' :: (Foldable1' t,Semigroup m) => (Identity a -> m) -> t a -> m
- foldMap1' = foldMap1_r
- ----
- -- Traversable1
- class Traversable1_r Identity t => Traversable1' t
- traverse1' :: (Traversable1' t,Apply f) => (a -> f b) -> t a -> f (t b)
- traverse1' f = traverse1_r (fmap Identity . f . runIdentity)
- ----
- -- Foldable
- class Foldable_r Identity t => Foldable' t
- foldMap' :: (Foldable' t,Monoid m) => (a -> m) -> t a -> m
- foldMap' f = foldMap_r (f . runIdentity)
- foldr' :: Foldable' t => (a -> b -> b) -> b -> t a -> b
- foldr' f = foldr_r (f . runIdentity)
- ----
- -- Traversable
- class Traversable_r Identity t => Traversable' t
- traverse' :: (Traversable' t,Applicative f) => (a -> f b) -> t a -> f (t b)
- traverse' f = traverse_r (fmap Identity . f . runIdentity)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement