put if statements within type constraints http://github.com/mikeizbicki/ifcxt

Latest on Hackage:0.1.1

This package is not currently in any snapshots. If you're interested in using it, we recommend adding it to Stackage Nightly. Doing so will make builds more reliable, and allow stackage.org to host generated Haddocks.

BSD3 licensed by Mike Izbicki
Maintained by mike@izbicki.me

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.

Depends on 2 packages:
Used by 1 package:
comments powered byDisqus