{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DefaultSignatures #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-}
module PyF.Class where
import Data.Int
import qualified Data.Text as SText
import qualified Data.Text.Lazy as LText
import Data.Word
import Numeric.Natural
data PyFCategory
=
PyFIntegral
|
PyFFractional
|
PyFString
type family PyFClassify t :: PyFCategory
type instance PyFClassify Integer = 'PyFIntegral
type instance PyFClassify Int = 'PyFIntegral
type instance PyFClassify Int8 = 'PyFIntegral
type instance PyFClassify Int16 = 'PyFIntegral
type instance PyFClassify Int32 = 'PyFIntegral
type instance PyFClassify Int64 = 'PyFIntegral
type instance PyFClassify Natural = 'PyFIntegral
type instance PyFClassify Word = 'PyFIntegral
type instance PyFClassify Word8 = 'PyFIntegral
type instance PyFClassify Word16 = 'PyFIntegral
type instance PyFClassify Word32 = 'PyFIntegral
type instance PyFClassify Word64 = 'PyFIntegral
type instance PyFClassify Float = 'PyFFractional
type instance PyFClassify Double = 'PyFFractional
type instance PyFClassify String = 'PyFString
type instance PyFClassify LText.Text = 'PyFString
type instance PyFClassify SText.Text = 'PyFString
class PyFToString t where
pyfToString :: t -> String
default pyfToString :: Show t => t -> String
pyfToString = show
instance PyFToString String where pyfToString = id
instance PyFToString LText.Text where pyfToString = LText.unpack
instance PyFToString SText.Text where pyfToString = SText.unpack
instance {-# OVERLAPPABLE #-} Show t => PyFToString t where pyfToString = show