it-has alternatives and similar packages
Based on the "Data" category.
Alternatively, view it-has alternatives based on common mentions on social networks and blogs.
-
semantic-source
Parsing, analyzing, and comparing source code across many languages -
lens
Lenses, Folds, and Traversals - Join us on web.libera.chat #haskell-lens -
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 -
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. -
discrimination
Fast linear time sorting and discrimination for a large class of data types -
reflection
Reifies arbitrary Haskell terms into types that can be reflected back into terms -
dependent-sum
Dependent sums and supporting typeclasses for comparing and displaying them -
dependent-map
Dependently-typed finite maps (partial dependent products) -
IORefCAS
A collection of different packages for CAS based data structures. -
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! -
scientific
Arbitrary-precision floating-point numbers represented using scientific notation -
text-icu
This package provides the Haskell Data.Text.ICU library, for performing complex manipulation of Unicode text.
WorkOS - The modern identity platform for B2B SaaS
Do you think we are missing an alternative of it-has or a related project?
README
it-has
This is a (nearly) drop-in replacement of data-has. The differences with the original package are that this one misses hasLens
and uses Generic
for its default implementation. Your initial reaction may be to start mourning the loss of hasLens
, but first take a look at the cool things you can do without it!
Reduce boilerplate! You can trim down this:
data Config =
Config
{ configLogEnv :: !LogEnv
, configJwtSettings :: !JWTSettings
, configMetrics :: !Metrics
, configEkgStore :: !EKG.Store }
-- Heavy manual instances, data-has only has default implementation for tuples
instance Has LogEnv Config where
getter = configLogEnv
modifier f v = v { configLogEnv = f (configLogEnv v) }
instance Has JWTSettings Config where
getter = configJwtSettings
modifier f v = v { configJwtSettings = f (configJwtSettings v) }
instance Has Metrics Config where
getter = configMetrics
modifier f v = v { configMetrics = f (configMetrics v) }
instance Has EKG.Store Config where
getter = configEkgStore
modifier f v = v { configEkgStore = f (configEkgStore v) }
To this:
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
data Config =
Config
{ configLogEnv :: !LogEnv
, configJwtSettings :: !JWTSettings
, configMetrics :: !Metrics
, configEkgStore :: !EKG.Store
} deriving (Generic, Has LogEnv, Has JWTSettings, Has Metrics, Has EKG.Store)
Another trick is that you can "force" a sum type to have a specific field defined. (and this is why you would use it-has
over simply generic-lens
)
E.g. you may want to define an Error
type and enforce that it always has an ErrorText
attached to it.
newtype ErrorText =
ErrorText Text
data Error =
ValidationError |
NotFound |
Critical |
Unauthorized
You can do that by deriving Has ErrorText
. The compiler will error until you have added an ErrorText
field to each representation.
data Error =
ValidationError ErrorText |
NotFound ErrorText |
Critical ErrorText |
Unauthorized ErrorText
deriving (Generic, Has ErrorText)
For more documentation and examples, please refer to the original package.