The ifcxt package

[Tags:bsd3, library, test]

This package introduces the ifCxt function, which lets your write if statements that depend on a polymorphic variable's class instances. For example, we can make a version of show that can be called on any type:

cxtShow :: forall a. IfCxt (Show a) => a -> String
cxtShow a = ifCxt (Proxy::Proxy (Show a))
    (show a)
    "<<unshowable>>"

Running this function in ghci, we get:

>>> cxtShow (1 :: Int)
"1"
>>> cxtShow (id :: a -> a)
"<<unshowable>>"

See the project webpage http://github.com/mikeizbicki/ifcxt for more details.

Properties

Versions 0.1.0.0, 0.1.1
Dependencies base (==4.8.*), template-haskell (==2.10.*) [details]
License BSD3
Author Mike Izbicki
Maintainer mike@izbicki.me
Category Control
Home page http://github.com/mikeizbicki/ifcxt
Source repository head: git clone http://github.com/mikeizbicki/ifcxt
Uploaded Wed Aug 3 21:52:43 UTC 2016 by MikeIzbicki
Distributions NixOS:0.1.1
Downloads 215 total (16 in the last 30 days)
Votes
1 []
Status Docs not available [build log]
All reported builds failed as of 2016-11-21 [all 2 reports]
Hackage Matrix CI

Modules

  • IfCxt
    • IfCxt.Examples

Downloads

Maintainer's Corner

For package maintainers and hackage trustees