ifcxt: put if statements within type constraints

[ bsd3, control, library ] [ Propose Tags ]

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)

Running this function in ghci, we get:

>>> cxtShow (1 :: Int)
>>> cxtShow (id :: a -> a)

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

Versions [RSS] [faq], 0.1.1
Dependencies base (==4.8.*), template-haskell (==2.10.*) [details]
License BSD-3-Clause
Author Mike Izbicki
Maintainer mike@izbicki.me
Category Control
Home page http://github.com/mikeizbicki/ifcxt
Source repo head: git clone http://github.com/mikeizbicki/ifcxt
Uploaded by MikeIzbicki at 2015-09-02T22:47:01Z
Distributions NixOS:0.1.1
Downloads 1449 total (14 in the last 30 days)
Rating 2.25 (votes: 2) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Hackage Matrix CI
Docs available [build log]
Last success reported on 2015-09-29 [all 3 reports]




Maintainer's Corner

For package maintainers and hackage trustees