{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DefaultSignatures #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE ImpredicativeTypes #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE Unsafe #-}
{-# LANGUAGE NoImplicitPrelude #-}
module GHC.Magic.Dict.Compat (
WithDict,
withDict,
) where
#if MIN_VERSION_ghc_prim(0,9,0)
import GHC.Magic.Dict (WithDict(), withDict)
#else
import GHC.TypeError.Compat (Unsatisfiable, unsatisfiable)
import GHC.TypeLits
import GHC.Types (RuntimeRep, TYPE)
class WithDict cls meth where
withDict_ :: forall {rr :: RuntimeRep} (r :: TYPE rr). meth -> ((cls) => r) -> r
default withDict_ ::
( Unsatisfiable
( 'Text "Class `"
':<>: 'ShowType WithDict
':<>: 'Text " does not support user-specified-instances."
':$$: 'Text "In the instance declaration for `"
':<>: 'ShowType (WithDict cls meth)
':<>: 'Text "'"
)
) =>
forall {rr :: RuntimeRep} (r :: TYPE rr).
meth ->
((cls) => r) ->
r
withDict_ = forall a. Bottom => a
unsatisfiable
withDict ::
forall cls meth {rr :: RuntimeRep} (r :: TYPE rr).
(WithDict cls meth) =>
meth ->
((cls) => r) ->
r
{-# INLINE withDict #-}
withDict :: forall (cls :: Constraint) meth r.
WithDict cls meth =>
meth -> (cls => r) -> r
withDict = forall (cls :: Constraint) meth r.
WithDict cls meth =>
meth -> (cls => r) -> r
withDict_ @cls @meth
#endif