barbies
Classes for working with types that can change clothes.
https://github.com/jcpetruzza/barbies#readme
| LTS Haskell 24.17: | 2.1.1.0 | 
| Stackage Nightly 2025-10-31: | 2.1.1.0 | 
| Latest on Hackage: | 2.1.1.0 | 
barbies-2.1.1.0@sha256:ec928dbc06fa00e1f323b9b7f4f5ba3cffcaa1e0d7d3cc275789a40a5a32f053,3238Module documentation for 2.1.1.0
barbies 
Types that are parametric on unary type-constructors that control their shapes are like Barbies that can wear different clothes to become a different doll. This is a common Haskell-idiom. E.g.,
data Person f
  = Person
      { name :: f String
      , age  :: f Int
      }
b1 :: Person Last       -- Barbie with a monoid structure
b2 :: Person (Const a)  -- container Barbie
b3 :: Person Identity   -- Barbie's new clothes
This package provides basic classes and abstractions to work with these types and easily transform them. See the docs to learn more.
Related packages
- barbies-th: Use Template Haskell to derive barbie-types from declarations that look like normal types.
- higgledy: Use Generics to give a barbie-type interface to a normal type.
- harg: Program-configuration (from command-line arguments, environment variables, configuration files, etc) via barbie-types
Changes
Changelog for barbies
2.1.1.0
- Correctly export the following functions, which were not
accessible in 2.1.0.0:
- Data.Barbie.bfor
- Data.Barbie.bfor_
- Data.Barbie.bforC
 
2.1.0.0
- Remove the deprecated interface from 1.x version
- Add flipped-argument versions of traversefunctions (Jack Kelly). By analogy toData.Traversable.forinbasethese are similarly-named:- ~~Data.Barbie.bfor~~
- ~~Data.Barbie.bfor_~~
- ~~Data.Barbie.bforC~~
- Data.Functor.Transformer.tfor
- Data.Functor.Transformer.tforC
- Data.Functor.Transformer.tfor_
- Barbies.Bi.btfor1
 
- ~~
2.0.5.0
- Add helper class Barbies.Constraints.(&) (#46)
2.0.4.0
- Add FunctorT and DistributiveT instances for AccumT
2.0.3.1
- Compatibility changes for GHC 9.2 (Dan Dart)
2.0.3.0
- Add Barbies.Bi.bttraverse_
- Add Barbies.Bi.btfoldMap
- Fix failure to derive Constraints{B,T} for proper bi-barbies.
- Builds with ghc 9 (Fumiaki Kinoshita)
2.0.2.0
- Add Barbies.Bare.WearTwotype family to support having field-specific newtype wrappers that get applied only to the covered barbie (Lennart Spitzner).
2.0.1.0
- Add the DistributiveBclass (Gergő Érdi).
2.0.0.0
- Builds with ghc 8.8, but drops support for ghc 8.0 and 8.2
- Fix failure to derive TraversableBandConstraintsBwhen using a type parameter not under the functor argument.
- Fix failure to derive instances for types with arguments of kind k -> Type.
- Fix failure to derive instances where functor arg is applied under a functor.
- Derive instances for nested barbies occurring under two functors (Matthew Peddie).
- Add foldMapCandbzipWithxC(Matthew Peddie).
- Create a Barbiesmodule, to contain wrappers, basic docs, etc.Data.Functor.Barbiecontains only functor-related stuff.
- Replace ProductBbyApplicativeB, with more lax laws. Now we can derive more instances than before, since arbitrary monoids are allowed as fields of the record.
- Add Data.Functor.Transformer, operations for bi-barbies, including support for nesting.
- Add a ErrorContainerwrapper, similar toContainerbut forEither e.
- Remove ProductBC, sincebdictscan now be defined in terms ofApplicativeBandConstraintsB.
- Remove functions deprecated on release 1.0
- Deprecate Data.Functor.Prod,(/*)and(/*/).
- Deprecate Data.Barbie, in favor ofData.Functor.Barbie.
- Deprecate Data.Barbie.Bare, in favor ofBarbies.Bare.
- Deprecate Data.Barbie.Constraints, in favor ofBarbies.Constraints.
1.1.3.0
- Wearwill raise a- TypeErrorinstead of getting stuck (Alex Peitsinis).
1.1.2.1
- Uploaded 1.1.2.0 was broken (missing btraverseC)
1.1.2.0
- Add traverseC(Ole Krüger).
- Fix typo in ProductB laws (thanks to Ben Radford).
1.1.1.0
- Add bmapC(Chris Penner).
1.1.0.0
- 
Make all classes poly-kinded (#7): a barbie can now be any type parameterised by a type (k -> Type). In particular, a (higher-kinded) barbie is a type parameterised by a barbie. Thanks to Ole Krüger.
- 
Add instances for functor transformers: Proxy,Const,Product,SumandCompose(Ole Krüger).
1.0.0.0
- 
Replaced ConstraintsOfinConstraintsBbyAllB, which allows constraints to be given onainstead of onf a. TheClassFclass lets us specify constraints onf aby doingAllB (ClassF c f) b.ConstraintsOfbecomes then a type alias. Credit goes to Csongor Kiss.
- 
ConstraintsOfwas ultimately deprecated in favour ofAllBF, which is shorter and more consistent withAllB.
- 
Renamed ConstraintsB(adjProof)toConstraintsB(baddDicts).
- 
Renamed ProofB(bproof)toProductBC(bdicts).
- 
Changed the way Wearworks: now wear-types need to have an extra type parameter that controls whether they areBareorCovered. This let us remove all the “magic” that was involved, in the sense that one couldn’t have instances ofFunctorB, etc, for wear-types wihtout usingunsafeCoerce(this was true also for handwritten instances).
- 
Added bsequence', a frequent specialisation ofbsequence.
- 
Added bfoldMap.
- 
Added buniqCandbmempty.
- 
Improved the internal instance derivation mechanism. We no longer need unsafeCoerceand the code should be in general indistinguishible from hand-written instances (not currently verified).
- 
Fixed support for barbie-types that have additional type parameters (#5). 
0.1.4.0
- 
Added btraverse_
- 
Added the trivial VoidandUnitbarbies
0.1.3.1
- Fixed issue on Barbie-types with strictness annotations.
0.1.3.0
- Use both MonoidandSemigroupas constraints for theMonoidinstance, so that this works with ghc 8.0 to 8.4 (Fraser Murray)
0.1.2.0
- Use Monoidand notSemigroupas constraints for theMonoidinstance
0.1.1.0
- Added instance Semigroup (Barbie b)to go along theMonoidinstance
0.1.0.1
- Works under GHC 8.0.2, but notice one needs to use empty instance
declarations, because ghc chokes on derivingclauses.
