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.


[Last Documentation]

  • IfCxt
    • IfCxt.Examples


Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


  • No Candidates
Versions [RSS], 0.1.1
Dependencies base (>=4.8 && <4.9), template-haskell (>=2.10 && <2.11) [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 2016-08-03T21:52:43Z
Reverse Dependencies 1 direct, 1 indirect [details]
Downloads 1640 total (4 in the last 30 days)
Rating 2.25 (votes: 2) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs not available [build log]
All reported builds failed as of 2016-11-21 [all 2 reports]