smash: Combinators for Maybe types

[ bsd3, data, library ] [ Propose Tags ] [ Report a vulnerability ]

Smash products are like the These datatype, only with a unit. You can think of this type as isomorphic to 'Maybe (These a b)'.


[Skip to Readme]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 0.1.0.0, 0.1.1.0, 0.1.2, 0.1.3, 0.2.0
Change log CHANGELOG.md
Dependencies base (>=4.15 && <4.23), bifunctors (>=5.5 && <5.7), binary (>=0.8 && <0.9), deepseq (>=1.4 && <1.6), hashable (>=1.3 && <1.6), mtl (>=2.2 && <2.4), template-haskell (>=2.2 && <3) [details]
Tested with ghc ==9.6.7 || ==9.8.4 || ==9.10.3 || ==9.12.4 || ==9.14.1
License BSD-3-Clause
Copyright (c) 2020-2026 Emily Pillmore <emilypi@cohomolo.gy>
Author Emily Pillmore
Maintainer emilypi@cohomolo.gy
Uploaded by topos at 2026-10-27T00:43:42Z
Category Data
Home page https://github.com/emilypi/smash
Bug tracker https://github.com/emilypi/smash/issues
Source repo head: git clone https://github.com/emilypi/smash.git
Distributions
Reverse Dependencies 7 direct, 0 indirect [details]
Downloads 1227 total (17 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2026-10-27 [all 1 reports]

Readme for smash-0.2.0

[back to package description]

smash: Combinators for Maybe types

CI Hackage

This package consists of 3 interesting datatypes and their respective monad transformers:

  • Wedge: Isomorphic to Maybe (Either a b). The Wedge datatype represents the coproduct in the category Hask* of pointed Hask types, called a wedge sum. One can derive this type as follows:

    Either (Maybe a) (Maybe b)
    ~ (1 + a) + (1 + b)
    -- units are the same via pushout
    ~ 1 + a + b
    ~ Maybe (Either a b)
    ~ Wedge a b
    
  • Can: Isomorphic to Maybe (These a b). The Can datatype represents the product in Hask*. One can derive this as follows:

    (Maybe a, Maybe a)
    ~ (1 + a) * (1 + b)
    -- products distribute over coproducts
    ~ 1 + b + a + a*b
    -- coproducts are associative
    ~ 1 + (b + a + a*b)
    ~ 1 + These a b
    ~ Maybe (These a b)
    ~ Can a b
    
  • Smash: Isomorphic to Maybe (a,b). The Smash datatype represents a special type of product, a smash product, in the category Hask*. The smash product is a symmetric, monoidal tensor in Hask* that is the quotient of Can over Wedge. It can be derived as follows:

    Can a b / Wedge a b
    ~ 1 + a + b + a*b / 1 + a + b
    -- reassoc coproduct
    ~ (1 + a + b) + a*b / 1 + a + b
    -- def. of quotient: (1 + a + b) ~ 1
    ~ 1 + a * b
    ~ Maybe (a,b)
    ~ Smash a b