{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE StandaloneDeriving #-}
module Generics.MRSOP.Opaque where
import Data.Type.Equality
import Generics.MRSOP.Util
data Kon
= KInt
| KInteger
| KFloat
| KDouble
| KBool
| KChar
| KString
deriving (Eq , Show)
data Singl (kon :: Kon) :: * where
SInt :: Int -> Singl 'KInt
SInteger :: Integer -> Singl 'KInteger
SFloat :: Float -> Singl 'KFloat
SDouble :: Double -> Singl 'KDouble
SBool :: Bool -> Singl 'KBool
SChar :: Char -> Singl 'KChar
SString :: String -> Singl 'KString
deriving instance Show (Singl k)
deriving instance Eq (Singl k)
instance EqHO Singl where
eqHO = (==)
instance ShowHO Singl where
showHO = show
eqSingl :: Singl k -> Singl k -> Bool
eqSingl = (==)
instance TestEquality Singl where
testEquality (SInt _) (SInt _) = Just Refl
testEquality (SInteger _) (SInteger _) = Just Refl
testEquality (SFloat _) (SFloat _) = Just Refl
testEquality (SDouble _) (SDouble _) = Just Refl
testEquality (SBool _) (SBool _) = Just Refl
testEquality (SChar _) (SChar _) = Just Refl
testEquality (SString _) (SString _) = Just Refl
testEquality _ _ = Nothing