correct direction of foldlMap

This commit is contained in:
Andrew Martin 2016-09-07 21:32:53 -04:00
parent adf88dd0e7
commit 9a550e5992
5 changed files with 14 additions and 11 deletions

View File

@ -1,5 +1,5 @@
name: colonnade name: colonnade
version: 0.4.1 version: 0.4.4
synopsis: Generic types and functions for columnar encoding and decoding synopsis: Generic types and functions for columnar encoding and decoding
description: Please see README.md description: Please see README.md
homepage: https://github.com/andrewthad/colonnade#readme homepage: https://github.com/andrewthad/colonnade#readme

View File

@ -32,7 +32,7 @@ runRowMonadic :: (Monad m, Monoid b)
-> a -> a
-> m b -> m b
runRowMonadic (Encoding v) g a = runRowMonadic (Encoding v) g a =
flip Internal.foldMapM v flip Internal.foldlMapM v
$ \e -> g (oneEncodingEncode e a) $ \e -> g (oneEncodingEncode e a)
runRowMonadicWith :: (Monad m) runRowMonadicWith :: (Monad m)

View File

@ -1,7 +1,7 @@
{-# LANGUAGE DeriveFunctor #-} {-# LANGUAGE DeriveFunctor #-}
module Colonnade.Internal where module Colonnade.Internal where
import Data.Foldable (foldrM) import Data.Foldable (foldrM,foldlM)
newtype EitherWrap a b = EitherWrap newtype EitherWrap a b = EitherWrap
{ getEitherWrap :: Either a b { getEitherWrap :: Either a b
@ -18,6 +18,6 @@ mapLeft :: (a -> b) -> Either a c -> Either b c
mapLeft _ (Right a) = Right a mapLeft _ (Right a) = Right a
mapLeft f (Left a) = Left (f a) mapLeft f (Left a) = Left (f a)
foldMapM :: (Foldable t, Monoid b, Monad m) => (a -> m b) -> t a -> m b foldlMapM :: (Foldable t, Monoid b, Monad m) => (a -> m b) -> t a -> m b
foldMapM f = foldrM (\a b -> fmap (flip mappend b) (f a)) mempty foldlMapM f = foldlM (\b a -> fmap (mappend b) (f a)) mempty

View File

@ -1,5 +1,5 @@
name: reflex-dom-colonnade name: reflex-dom-colonnade
version: 0.4.3 version: 0.4.4
synopsis: Use colonnade with reflex-dom synopsis: Use colonnade with reflex-dom
description: Please see README.md description: Please see README.md
homepage: https://github.com/andrewthad/colonnade#readme homepage: https://github.com/andrewthad/colonnade#readme
@ -18,7 +18,7 @@ library
Reflex.Dom.Colonnade Reflex.Dom.Colonnade
build-depends: build-depends:
base >= 4.7 && < 5 base >= 4.7 && < 5
, colonnade >= 0.4.1 , colonnade >= 0.4.4
, contravariant , contravariant
, vector , vector
, reflex , reflex

View File

@ -124,8 +124,8 @@ dynamicEventful :: (MonadWidget t m, Foldable f, Semigroup e)
dynamicEventful tableAttrs as encoding@(Encoding v) = do dynamicEventful tableAttrs as encoding@(Encoding v) = do
elAttr "table" tableAttrs $ do elAttr "table" tableAttrs $ do
b1 <- theadBuild encoding b1 <- theadBuild encoding
b2 <- el "tbody" $ flip foldMapM as $ \a -> do b2 <- el "tbody" $ flip foldlMapM as $ \a -> do
el "tr" $ flip foldMapM v $ \(OneEncoding _ encode) -> do el "tr" $ flip foldlMapM v $ \(OneEncoding _ encode) -> do
dynPair <- mapDyn encode a dynPair <- mapDyn encode a
dynAttrs <- mapDyn cellAttrs dynPair dynAttrs <- mapDyn cellAttrs dynPair
dynContent <- mapDyn cellContents dynPair dynContent <- mapDyn cellContents dynPair
@ -134,8 +134,11 @@ dynamicEventful tableAttrs as encoding@(Encoding v) = do
switchPromptly never e switchPromptly never e
return (mappend b1 b2) return (mappend b1 b2)
foldMapM :: (Foldable t, Monoid b, Monad m) => (a -> m b) -> t a -> m b -- foldMapM :: (Foldable t, Monoid b, Monad m) => (a -> m b) -> t a -> m b
foldMapM f = foldrM (\a b -> fmap (flip mappend b) (f a)) mempty -- foldMapM f = foldlM (\b a -> fmap (flip mappend b) (f a)) mempty
foldlMapM :: (Foldable t, Monoid b, Monad m) => (a -> m b) -> t a -> m b
foldlMapM f = foldlM (\b a -> fmap (mappend b) (f a)) mempty
foldAlternativeM :: (Foldable t, Monoid b, Monad m) => (a -> m b) -> t a -> m b foldAlternativeM :: (Foldable t, Monoid b, Monad m) => (a -> m b) -> t a -> m b
foldAlternativeM f = foldrM (\a b -> fmap (flip mappend b) (f a)) mempty foldAlternativeM f = foldrM (\a b -> fmap (flip mappend b) (f a)) mempty