Classes for working with types that can change clothes.

Version on this page:
LTS Haskell 22.18:
Stackage Nightly 2024-04-22:
Latest on Hackage:

See all snapshots barbies appears in

BSD-3-Clause licensed by Daniel Gorin
Maintained by [email protected]
This version can be pinned in stack with:barbies-,2618
Depends on 2 packages(full list with versions):

barbies Build Status

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 Barbie f
  = Barbie
      { name :: f String
      , age  :: f Int

b1 :: Barbie Last       -- Barbie with a monoid structure
b2 :: Barbie (Const a)  -- container Barbie
b3 :: Barbie Identity   -- Barbie's new clothes

This package provides basic classes and abstractions to work with these types and easily transform them.


Changelog for barbies

  • Wear will raise a TypeError instead of getting stuck (Alex Peitsinis).

  • Uploaded was broken (missing btraverseC)

  • Add traverseC (Ole Krüger).
  • Fix typo in ProductB laws (thanks to Ben Radford).

  • Add bmapC (Chris Penner).

  • 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, Sum and Compose (Ole Krüger).

  • Replaced ConstraintsOf in ConstraintsB by AllB, which allows constraints to be given on a instead of on f a. The ClassF class lets us specify constraints on f a by doing AllB (ClassF c f) b. ConstraintsOf becomes then a type alias. Credit goes to Csongor Kiss.

  • ConstraintsOf was ultimately deprecated in favour of AllBF, which is shorter and more consistent with AllB.

  • Renamed ConstraintsB(adjProof) to ConstraintsB(baddDicts).

  • Renamed ProofB(bproof) to ProductBC(bdicts).

  • Changed the way Wear works: now wear-types need to have an extra type parameter that controls whether they are Bare or Covered. This let us remove all the “magic” that was involved, in the sense that one couldn’t have instances of FunctorB, etc, for wear-types wihtout using unsafeCoerce (this was true also for handwritten instances).

  • Added bsequence', a frequent specialisation of bsequence.

  • Added bfoldMap.

  • Added buniqC and bmempty.

  • Improved the internal instance derivation mechanism. We no longer need unsafeCoerce and 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).

  • Added btraverse_

  • Added the trivial Void and Unit barbies

  • Fixed issue on Barbie-types with strictness annotations.

  • Use both Monoid and Semigroup as constraints for the Monoid instance, so that this works with ghc 8.0 to 8.4 (Fraser Murray)

  • Use Monoid and not Semigroup as constraints for the Monoid instance

  • Added instance Semigroup (Barbie b) to go along the Monoid instance

  • Works under GHC 8.0.2, but notice one needs to use empty instance declarations, because ghc chokes on deriving clauses. - Initial release