f-algebra-gen alternatives and similar packages
Based on the "Data" category.
Alternatively, view f-algebra-gen alternatives based on common mentions on social networks and blogs.
-
lens
Lenses, Folds, and Traversals - Join us on web.libera.chat #haskell-lens -
semantic-source
Parsing, analyzing, and comparing source code across many languages -
text
Haskell library for space- and time-efficient operations over Unicode text. -
code-builder
Packages for defining APIs, running them, generating client code and documentation. -
unordered-containers
Efficient hashing-based container types -
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 -
holmes
A reference library for constraint-solving with propagators and CDCL. -
resource-pool
A high-performance striped resource pooling implementation for Haskell -
primitive
This package provides various primitive memory-related operations. -
binary
Efficient, pure binary serialisation using ByteStrings in Haskell. -
discrimination
Fast linear time sorting and discrimination for a large class of data types -
json-autotype
Automatic Haskell type inference from JSON input -
reflection
Reifies arbitrary Haskell terms into types that can be reflected back into terms -
audiovisual
Extensible records, variants, structs, effects, tangles -
IORefCAS
A collection of different packages for CAS based data structures. -
dependent-map
Dependently-typed finite maps (partial dependent products) -
dependent-sum
Dependent sums and supporting typeclasses for comparing and displaying them -
orgmode-parse
Attoparsec parser combinators for parsing org-mode structured text! -
scientific
Arbitrary-precision floating-point numbers represented using scientific notation -
bifunctors
Haskell 98 bifunctors, bifoldables and bitraversables -
protobuf
An implementation of Google's Protocol Buffers in Haskell. -
streaming
An optimized general monad transformer for streaming applications, with a simple prelude of functions -
safecopy
An extension to Data.Serialize with built-in version control -
text-icu
This package provides the Haskell Data.Text.ICU library, for performing complex manipulation of Unicode text. -
uuid-types
A Haskell library for creating, printing and parsing UUIDs
Access the most powerful time series database as a service
Do you think we are missing an alternative of f-algebra-gen or a related project?
README
F-Algebra Data Combinator Generator
Generate an f-algebra combinator from any data type.
https://hackage.haskell.org/package/f-algebra-gen-0.1.0.2
Description
This library provides a function to generate a special f-algebra combinator from any data type (GADTs are not currently supported).
This was inspired by the recursion-schemes library where they have a function to automagically generate a base functor. Although, this new base functor data type has custom constructors and to define the *-morphism algebras turns into boring pattern matching.
So, this library provides a function called makeCombinator
that produces a
nice combinator to deal with data types as they were defined in terms of Pairs
((,)
) and Sums (Either
). With this nice combinator we are able to view a
data type as its equivalent categorical isomorphism and manipulate it with an
interface similar as the either
function provided from base
.
Example
To create this special combinator you just need to call makeCombinator ''<data
type name>
as in the example below:
-- List type
data List a = Nil | List a (List a)
makeBaseFunctor ''List
makeCombinator ''ListF
This example will generate the following code:
makeCombinator ''ListF
======>
listf f_acw7 f_acw8 Nil = f_acw7 ()
listf f_acw7 f_acw8 (Cons a_acw9 a_acwa) = f_acw8 (a_acw9, a_acwa)
As you can see it's pretty close as to have the type defined as the set of
sums and pairs data List a = Either () (a, List a)
, which we could then use
either
function as well as other convinent (,)
combinators.
An important note is that the generated function has always the same name as the data type but in low characters and the order of the functions to be applied to the type constructors it's the same order which they were declared.
A simple example on how we can beneficiate from using this special combinator when defining catamorphisms using recursion-schemes:
Without the combinator:
length :: [a] -> Int length = cata gene where gene Nil = 0 gene (Cons a x) = x + 1
With the combinator:
makeCombinator'' ListF
length :: [a] -> Int length = cata (listf (const 0) (succ . snd))
I recognize that for such a simple data type and catamorphism it's hard to see
any gain in readability/implementation. But with this special combinator it's a
lot easier to go from paper to code as it's almost a direct translation.
There's a fully working example in the `examples` folder that uses the
recursion-schemes library as well as a nice small program calculus (AoP
inspired) combinators library to show how simple and straightforward it is to
use it with this new combinator.