module Rerefined.Refined where

import Language.Haskell.TH.Syntax ( Lift )

-- | @a@ refined with predicate @p@.
newtype Refined p a = Refined a
    deriving stock ((forall (m :: Type -> Type). Quote m => Refined p a -> m Exp)
-> (forall (m :: Type -> Type).
    Quote m =>
    Refined p a -> Code m (Refined p a))
-> Lift (Refined p a)
forall k (p :: k) a (m :: Type -> Type).
(Lift a, Quote m) =>
Refined p a -> m Exp
forall k (p :: k) a (m :: Type -> Type).
(Lift a, Quote m) =>
Refined p a -> Code m (Refined p a)
forall t.
(forall (m :: Type -> Type). Quote m => t -> m Exp)
-> (forall (m :: Type -> Type). Quote m => t -> Code m t) -> Lift t
forall (m :: Type -> Type). Quote m => Refined p a -> m Exp
forall (m :: Type -> Type).
Quote m =>
Refined p a -> Code m (Refined p a)
$clift :: forall k (p :: k) a (m :: Type -> Type).
(Lift a, Quote m) =>
Refined p a -> m Exp
lift :: forall (m :: Type -> Type). Quote m => Refined p a -> m Exp
$cliftTyped :: forall k (p :: k) a (m :: Type -> Type).
(Lift a, Quote m) =>
Refined p a -> Code m (Refined p a)
liftTyped :: forall (m :: Type -> Type).
Quote m =>
Refined p a -> Code m (Refined p a)
Lift, Int -> Refined p a -> ShowS
[Refined p a] -> ShowS
Refined p a -> String
(Int -> Refined p a -> ShowS)
-> (Refined p a -> String)
-> ([Refined p a] -> ShowS)
-> Show (Refined p a)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
forall k (p :: k) a. Show a => Int -> Refined p a -> ShowS
forall k (p :: k) a. Show a => [Refined p a] -> ShowS
forall k (p :: k) a. Show a => Refined p a -> String
$cshowsPrec :: forall k (p :: k) a. Show a => Int -> Refined p a -> ShowS
showsPrec :: Int -> Refined p a -> ShowS
$cshow :: forall k (p :: k) a. Show a => Refined p a -> String
show :: Refined p a -> String
$cshowList :: forall k (p :: k) a. Show a => [Refined p a] -> ShowS
showList :: [Refined p a] -> ShowS
Show) -- TODO Show? useful but meh?

-- | Strip the refinement from a 'Refined'.
--
-- This is kept as a separate function for prettier @'Show' 'Refined'@ output.
unrefine :: Refined p a -> a
unrefine :: forall {k} (p :: k) a. Refined p a -> a
unrefine (Refined a
a) = a
a