The proxied package

[Tags:bsd3, library]

proxied is a simple library that exports a function to convert constant functions to ones that take a proxy value in the Data.Proxied module. This is useful for retrofiting typeclasses that have functions that return a constant value for any value of a particular type (but still need to consume some value, since one of the parameterized types must appear in a typeclass function). Often, these functions are given undefined as an argument, which might be considered poor design.

Proxy, however, does not carry any of the error-throwing risks of undefined, so it is much more preferable to take Proxy as an argument to a constant function instead of undefined. Unfortunately, Proxy was included in base until GHC 7.8, so many of base's typeclasses still contain constant functions that aren't amenable to passing Proxy. proxied addresses this issue by providing variants of those typeclass functions that take an explicit proxy value.

This library also contains the Data.Proxyless module, which works in the opposite direction. That is, one can take functions which take Proxy (or undefined) as an argument and convert them to functions which take no arguments. This trick relies on the -XTypeApplications extension, so it is only available with GHC 8.0 or later.


[Skip to Readme]

Properties

Versions 0.1, 0.1.1, 0.2
Change log CHANGELOG.md
Dependencies base (>=4.3 && <5), generic-deriving (>=1.10.1 && <2), tagged (>=0.4.4 && <1) [details]
License BSD3
Copyright (C) 2016 Ryan Scott
Author Ryan Scott
Maintainer Ryan Scott <ryan.gl.scott@gmail.com>
Stability Provisional
Category Data
Home page https://github.com/RyanGlScott/proxied
Bug tracker https://github.com/RyanGlScott/proxied/issues
Source repository head: git clone https://github.com/RyanGlScott/proxied
Uploaded Sat Apr 16 22:58:29 UTC 2016 by ryanglscott
Distributions LTSHaskell:0.2, NixOS:0.2, Stackage:0.2, Tumbleweed:0.2
Downloads 167 total (10 in the last 30 days)
Votes
0 []
Status Docs available [build log]
Last success reported on 2016-04-16 [all 1 reports]

Modules

[Index]

Downloads

Maintainer's Corner

For package maintainers and hackage trustees

Readme for proxied

Readme for proxied-0.2

proxied

Hackage Hackage Dependencies Haskell Programming Language BSD3 License Build

proxied is a simple library that exports a function to convert constant functions to ones that take a proxy value in the Data.Proxied. This is useful for retrofiting typeclasses that have functions that return a constant value for any value of a particular type (but still need to consume some value, since one of the parameterized types must appear in a typeclass function). Often, these functions are given undefined as an argument, which might be considered poor design.

Proxy, however, does not carry any of the error-throwing risks of undefined, so it is much more preferable to take Proxy as an argument to a constant function instead of undefined. Unfortunately, Proxy was included in base until GHC 7.8, so many of base's typeclasses still contain constant functions that aren't amenable to passing Proxy. proxied addresses this issue by providing variants of those typeclass functions that take an explicit proxy value.

This library also contains the "Data.Proxyless" module, which works in the opposite direction. That is, one can take functions which take Proxy (or undefined) as an argument and convert them to functions which take no arguments. This trick relies on the -XTypeApplications extension, so it is only available with GHC 8.0 or later.