Popularity
2.6
Declining
Activity
0.0
Stable
2
3
0
Monthly Downloads: 3
Programming language: Haskell
License: MIT License
Tags:
Data
Latest version: v0.1.0.0
cmf alternatives and similar packages
Based on the "Data" category.
Alternatively, view cmf alternatives based on common mentions on social networks and blogs.
-
semantic-source
Parsing, analyzing, and comparing source code across many languages -
code-builder
Packages for defining APIs, running them, generating client code and documentation. -
text
Haskell library for space- and time-efficient operations over Unicode text. -
compendium-client
Mu (μ) is a purely functional framework for building micro services. -
cassava
A CSV parsing and encoding library optimized for ease of use and high performance -
primitive
This package provides various primitive memory-related operations. -
resource-pool
A high-performance striped resource pooling implementation for Haskell -
discrimination
Fast linear time sorting and discrimination for a large class of data types -
dependent-map
Dependently-typed finite maps (partial dependent products) -
dependent-sum
Dependent sums and supporting typeclasses for comparing and displaying them -
streaming
An optimized general monad transformer for streaming applications, with a simple prelude of functions -
orgmode-parse
Attoparsec parser combinators for parsing org-mode structured text! -
reflection
Reifies arbitrary Haskell terms into types that can be reflected back into terms -
scientific
Arbitrary-precision floating-point numbers represented using scientific notation
Tired of breaking your main and manually rebasing outdated pull requests?
Managing outdated pull requests is time-consuming. Mergify's Merge Queue automates your pull request management & merging. It's fully integrated to GitHub & coordinated with any CI. Start focusing on code. Try Mergify for free.
Promo
blog.mergify.com
Do you think we are missing an alternative of cmf or a related project?
README
cmf
What is it
This library provides concurrent folds for commutative monoids.
This is useful when you have some IO-bound task which meets at least the following two conditions:
- It needs to be run over potentially many of the same type of input
- The output can be combined in a commutative fashion
How to use it
-- Example 1: Grabbing data from a bunch of nodes (represented as just IPv4 addresses)
{-# language PackageImports #-}
module Main (main) where
-- intended to be imported qualified
import qualified Cmf
import "ip" Net.IPv4 (IPv4)
main :: IO ()
main = do
nodes <- readNodesFromFile "some_nodes.txt"
-- the list monoid is 'commutative' if we don't care about ordering
someData <- Cmf.foldMap reachOutToNodeAndGetData nodes
print someData
data SomeData = SomeData
deriving (Show)
reachOutToNodeAndGetData :: IPv4 -> IO [SomeData]
reachOutToNodeAndGetData = ...
readNodesFromFile :: FilePath -> IO [IPv4]
readNodesFromFile = ...
-- Example 2: Sending out emails concurrently
module Main (main) where
-- intended to be imported qualified
import qualified Cmf
import Data.Map (Map)
main :: IO ()
main = do
emails <- getWhoShouldBeNotifiedOnEvent AccountSetupFinished
errs <- Cmf.foldMapWithKey (\k v -> (:[]) <$> sendEmail k v) emails
print errs
-- opaque data types, address and content of email
data EmailAddress = EmailAddress
deriving (Show)
data EmailContent = EmailContent
deriving (Show)
-- failed to send the email - address and error message
data EmailError = EmailError EmailAddress String
deriving (Show)
sendEmail :: EmailAddress -> EmailContent -> IO (Either EmailError ())
sendEmail = ...
data Event = AccountSetupFinished | SomethingElse
getWhoShouldBeNotifiedOnEvent :: Event -> IO (Map EmailAddress EmailContent)
getWhoShouldBeNotifiedOnEvent = ...