-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A package for working with nullary type classes. -- -- Work with nullary type classes without orphan instances. @package nullary @version 0.1.0.0 -- | Provides a framework for defining and using nullary type classes -- without needing orphan instances. To do this requires some evil to -- locally generate a type class instances. This library encapsulates -- that evil and provides a mechanism for safely defining new nullary -- type classes. -- -- To define a nullary type class, you use the following pattern: -- --
-- -- The following four extensions are necessary.
-- {-# LANGUAGE FlexibleContexts #-}
-- {-# LANGUAGE MultiParamTypeClasses #-}
-- {-# LANGUAGE Rank2Types #-}
-- {-# LANGUAGE UndecidableInstances #-}
--
-- -- Not exported unless you want to allow users to opt out of
-- -- the checking by making an instance for Tag PartialTag.
-- data PartialTag
--
-- -- The nullary type class. It can have members, but it's not
-- -- clear this accomplishes anything.
-- class Partial
--
-- -- Enable this library. Instances like this unfortunately
-- -- require UndecidableInstances.
-- instance Tag PartialTag => Partial
--
-- -- Wrap unsafeTag for user convenience.
-- partial :: (Partial => a) -> a
-- partial = unsafeTag (Proxy :: Proxy PartialTag)
-- {-# INLINE partial #-}
--
-- -- Define your functions using the Partial class.
-- head :: Partial => [a] -> a
-- head (x:xs) = x
--
module Type.Class.Nullary
-- | Class for declaring tagged nullary instances. See module description.
class Tag t
-- | Unsafely cast off the Tag constraint. This should only be used at the
-- "top-level" of an application. In practice, specializations of this
-- should be provided, e.g. unsafeUnsafe. This uses the same evil as
-- Data.Reflect.
unsafeTag :: Proxy t -> (Tag t => r) -> r
-- | A concrete, poly-kinded proxy type
data Proxy (t :: k) :: k -> *
Proxy :: Proxy
module Type.Class.Partial
-- | Nullary type class to mark partial functions, e.g. head.
class Partial
-- | Prefer partial. However, if you want to disable Partial
-- wholesale, make an orphan instance of Tag for this type. NEVER put an
-- instance of this in a library.
data PartialTag
-- | Accept the possibility of partiality.
partial :: (Partial => a) -> a
instance Type.Class.Nullary.Tag Type.Class.Partial.PartialTag => Type.Class.Partial.Partial
module Type.Class.Unsafe
-- | Nullary type class to mark unsafe functions, like unsafePerformIO.
class Unsafe
-- | Unsafely ignore Unsafe marker.
unsafeUnsafe :: (Unsafe => a) -> a
instance Type.Class.Nullary.Tag Type.Class.Unsafe.UnsafeTag => Type.Class.Unsafe.Unsafe