{-# LANGUAGE AllowAmbiguousTypes #-}

module Language.Parser.Ptera.Data.HEnum where

import           Language.Parser.Ptera.Prelude

import qualified Type.Membership               as Membership
import qualified Type.Membership.Internal      as MembershipInternal

type T = HEnum

newtype HEnum (as :: [k]) = UnsafeHEnum
    {
        HEnum as -> Int
unsafeHEnum :: Int
    }
    deriving (HEnum as -> HEnum as -> Bool
(HEnum as -> HEnum as -> Bool)
-> (HEnum as -> HEnum as -> Bool) -> Eq (HEnum as)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
forall k (as :: [k]). HEnum as -> HEnum as -> Bool
/= :: HEnum as -> HEnum as -> Bool
$c/= :: forall k (as :: [k]). HEnum as -> HEnum as -> Bool
== :: HEnum as -> HEnum as -> Bool
$c== :: forall k (as :: [k]). HEnum as -> HEnum as -> Bool
Eq, Int -> HEnum as -> ShowS
[HEnum as] -> ShowS
HEnum as -> String
(Int -> HEnum as -> ShowS)
-> (HEnum as -> String) -> ([HEnum as] -> ShowS) -> Show (HEnum as)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
forall k (as :: [k]). Int -> HEnum as -> ShowS
forall k (as :: [k]). [HEnum as] -> ShowS
forall k (as :: [k]). HEnum as -> String
showList :: [HEnum as] -> ShowS
$cshowList :: forall k (as :: [k]). [HEnum as] -> ShowS
show :: HEnum as -> String
$cshow :: forall k (as :: [k]). HEnum as -> String
showsPrec :: Int -> HEnum as -> ShowS
$cshowsPrec :: forall k (as :: [k]). Int -> HEnum as -> ShowS
Show)

henum :: forall a as. Membership.Membership as a -> HEnum as
henum :: Membership as a -> HEnum as
henum Membership as a
m = Int -> HEnum as
forall k (as :: [k]). Int -> HEnum as
UnsafeHEnum do Membership as a -> Int
forall k (xs :: [k]) (x :: k). Membership xs x -> Int
Membership.getMemberId Membership as a
m

henumA :: forall a as. Membership.Member as a => HEnum as
henumA :: HEnum as
henumA = Membership as a -> HEnum as
forall k (a :: k) (as :: [k]). Membership as a -> HEnum as
henum do Member as a => Membership as a
forall k (xs :: [k]) (x :: k). Member xs x => Membership xs x
MembershipInternal.membership @as @a

unHEnum :: forall a as. Membership.Membership as a -> HEnum as -> Bool
unHEnum :: Membership as a -> HEnum as -> Bool
unHEnum Membership as a
m (UnsafeHEnum Int
i) = Membership as a -> Int
forall k (xs :: [k]) (x :: k). Membership xs x -> Int
Membership.getMemberId Membership as a
m Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
i