{-# LINE 1 "src/Foreign/R/Type.hsc" #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE ExistentialQuantification #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LINE 11 "src/Foreign/R/Type.hsc" #-}
{-# OPTIONS_GHC -fno-warn-unticked-promoted-constructors #-}
{-# LINE 13 "src/Foreign/R/Type.hsc" #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
module Foreign.R.Type
( SEXPTYPE(..)
, SSEXPTYPE
, Sing(..)
, Logical(..)
, PairList
, IsVector
, IsGenericVector
, IsList
, IsPairList
, IsExpression
) where
import Foreign.R.Constraints
import Internal.Error
import qualified Language.Haskell.TH.Syntax as Hs
import qualified Language.Haskell.TH.Lib as Hs
import Data.Singletons.TH
import Control.DeepSeq (NFData(..))
import Foreign.R.Context
data SEXPTYPE
= Nil
| Symbol
| List
| Closure
| Env
| Promise
| Lang
| Special
| Builtin
| Char
| Logical
| Int
| Real
| Complex
| String
| DotDotDot
| Any
| Vector
| Expr
| Bytecode
| ExtPtr
| WeakRef
| Raw
| S4
| New
| Free
| Fun
deriving (Eq, Ord, Show)
instance Enum SEXPTYPE where
fromEnum Nil = 0
{-# LINE 106 "src/Foreign/R/Type.hsc" #-}
fromEnum Symbol = 1
{-# LINE 107 "src/Foreign/R/Type.hsc" #-}
fromEnum List = 2
{-# LINE 108 "src/Foreign/R/Type.hsc" #-}
fromEnum Closure = 3
{-# LINE 109 "src/Foreign/R/Type.hsc" #-}
fromEnum Env = 4
{-# LINE 110 "src/Foreign/R/Type.hsc" #-}
fromEnum Promise = 5
{-# LINE 111 "src/Foreign/R/Type.hsc" #-}
fromEnum Lang = 6
{-# LINE 112 "src/Foreign/R/Type.hsc" #-}
fromEnum Special = 7
{-# LINE 113 "src/Foreign/R/Type.hsc" #-}
fromEnum Builtin = 8
{-# LINE 114 "src/Foreign/R/Type.hsc" #-}
fromEnum Char = 9
{-# LINE 115 "src/Foreign/R/Type.hsc" #-}
fromEnum Logical = 10
{-# LINE 116 "src/Foreign/R/Type.hsc" #-}
fromEnum Int = 13
{-# LINE 117 "src/Foreign/R/Type.hsc" #-}
fromEnum Real = 14
{-# LINE 118 "src/Foreign/R/Type.hsc" #-}
fromEnum Complex = 15
{-# LINE 119 "src/Foreign/R/Type.hsc" #-}
fromEnum String = 16
{-# LINE 120 "src/Foreign/R/Type.hsc" #-}
fromEnum DotDotDot = 17
{-# LINE 121 "src/Foreign/R/Type.hsc" #-}
fromEnum Any = 18
{-# LINE 122 "src/Foreign/R/Type.hsc" #-}
fromEnum Vector = 19
{-# LINE 123 "src/Foreign/R/Type.hsc" #-}
fromEnum Expr = 20
{-# LINE 124 "src/Foreign/R/Type.hsc" #-}
fromEnum Bytecode = 21
{-# LINE 125 "src/Foreign/R/Type.hsc" #-}
fromEnum ExtPtr = 22
{-# LINE 126 "src/Foreign/R/Type.hsc" #-}
fromEnum WeakRef = 23
{-# LINE 127 "src/Foreign/R/Type.hsc" #-}
fromEnum Raw = 24
{-# LINE 128 "src/Foreign/R/Type.hsc" #-}
fromEnum S4 = 25
{-# LINE 129 "src/Foreign/R/Type.hsc" #-}
fromEnum New = 30
{-# LINE 130 "src/Foreign/R/Type.hsc" #-}
fromEnum Free = 31
{-# LINE 131 "src/Foreign/R/Type.hsc" #-}
fromEnum Fun = 99
{-# LINE 132 "src/Foreign/R/Type.hsc" #-}
toEnum (0) = Nil
{-# LINE 134 "src/Foreign/R/Type.hsc" #-}
toEnum (1) = Symbol
{-# LINE 135 "src/Foreign/R/Type.hsc" #-}
toEnum (2) = List
{-# LINE 136 "src/Foreign/R/Type.hsc" #-}
toEnum (3) = Closure
{-# LINE 137 "src/Foreign/R/Type.hsc" #-}
toEnum (4) = Env
{-# LINE 138 "src/Foreign/R/Type.hsc" #-}
toEnum (5) = Promise
{-# LINE 139 "src/Foreign/R/Type.hsc" #-}
toEnum (6) = Lang
{-# LINE 140 "src/Foreign/R/Type.hsc" #-}
toEnum (7) = Special
{-# LINE 141 "src/Foreign/R/Type.hsc" #-}
toEnum (8) = Builtin
{-# LINE 142 "src/Foreign/R/Type.hsc" #-}
toEnum (9) = Char
{-# LINE 143 "src/Foreign/R/Type.hsc" #-}
toEnum (10) = Logical
{-# LINE 144 "src/Foreign/R/Type.hsc" #-}
toEnum (13) = Int
{-# LINE 145 "src/Foreign/R/Type.hsc" #-}
toEnum (14) = Real
{-# LINE 146 "src/Foreign/R/Type.hsc" #-}
toEnum (15) = Complex
{-# LINE 147 "src/Foreign/R/Type.hsc" #-}
toEnum (16) = String
{-# LINE 148 "src/Foreign/R/Type.hsc" #-}
toEnum (17) = DotDotDot
{-# LINE 149 "src/Foreign/R/Type.hsc" #-}
toEnum (18) = Any
{-# LINE 150 "src/Foreign/R/Type.hsc" #-}
toEnum (19) = Vector
{-# LINE 151 "src/Foreign/R/Type.hsc" #-}
toEnum (20) = Expr
{-# LINE 152 "src/Foreign/R/Type.hsc" #-}
toEnum (21) = Bytecode
{-# LINE 153 "src/Foreign/R/Type.hsc" #-}
toEnum (22) = ExtPtr
{-# LINE 154 "src/Foreign/R/Type.hsc" #-}
toEnum (23) = WeakRef
{-# LINE 155 "src/Foreign/R/Type.hsc" #-}
toEnum (24) = Raw
{-# LINE 156 "src/Foreign/R/Type.hsc" #-}
toEnum (25) = S4
{-# LINE 157 "src/Foreign/R/Type.hsc" #-}
toEnum (30) = New
{-# LINE 158 "src/Foreign/R/Type.hsc" #-}
toEnum (31) = Free
{-# LINE 159 "src/Foreign/R/Type.hsc" #-}
toEnum (99) = Fun
{-# LINE 160 "src/Foreign/R/Type.hsc" #-}
toEnum _ = violation "toEnum" "Unknown R type."
instance NFData SEXPTYPE where
rnf = (`seq` ())
genSingletons [''SEXPTYPE]
instance Hs.Lift SEXPTYPE where
lift a = [| $(Hs.conE (Hs.mkName $ "Foreign.R.Type." ++ show a)) |]
type PairList = List
type IsVector (a :: SEXPTYPE) = (SingI a, a :∈ 'Char ': 'Logical ': 'Int ': 'Real ': 'Complex ': 'String ': 'Vector ': 'Expr ': 'WeakRef ': 'Raw ': '[])
{-# LINE 189 "src/Foreign/R/Type.hsc" #-}
type IsGenericVector (a :: SEXPTYPE) = (SingI a, a :∈ [Vector, Expr, WeakRef])
type IsList (a :: SEXPTYPE) = (SingI a, a :∈ 'Char ': 'Logical ': 'Int ': 'Real ': 'Complex ': 'String ': 'Vector ': 'Expr ': 'WeakRef ': 'Raw ': List ': '[])
{-# LINE 196 "src/Foreign/R/Type.hsc" #-}
type IsPairList (a :: SEXPTYPE) = (SingI a, a :∈ [List, Nil])
type IsExpression (a :: SEXPTYPE) = (SingI a, a :∈ [Lang, Expr, Symbol])