Skip to content

awpr/attenuation

This branch is 2 commits ahead of google/hs-attenuation:main.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

10ea4fd · Mar 12, 2023

History

31 Commits
Sep 23, 2021
Mar 12, 2023
Mar 12, 2023
Sep 3, 2021
Apr 20, 2021
Apr 20, 2021
Sep 20, 2021
Mar 12, 2023
Oct 11, 2021

Repository files navigation

attenuation

Uni-directional coercions, or representational subtyping relations.

Stack CI

Disclaimer

This is not an officially supported Google product.

Hackage Status

  • attenuation Uploaded Haddock

Overview

This package provides Attenuations, which act as uni-directional coercions, or representational subtyping relations.

Like Coercions, these can be used directly to coerce between their type parameters at zero runtime cost, or lifted to operate over "larger" types.

Unlike Coercions, these can be used only in one direction, from a "weaker" type to a "stronger" type. Accordingly, they have additional restrictions on lifting through type constructors: they must respect the variance (covariance or contravariance) of the type being lifted. Lifting an Attenuation covariantly lets you coerce from, e.g., [Fin n] -> [Int], but not vice versa; while lifting contravariantly lets you coerce from e.g. Op Bool Int -> Op Bool (Fin n), but not vice versa.

About

Unidirectional coercions for Haskell

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Haskell 100.0%