module Spark.Core.Types(
DataType,
Nullable(..),
TupleEquivalence(..),
NameTuple(..),
SQLType,
columnType,
SQLTypeable,
buildType,
StructField,
StructType,
castType,
catNodePath
) where
import Formatting
import Spark.Core.Internal.TypesStructures
import Spark.Core.Internal.TypesGenerics
import Spark.Core.Internal.TypesFunctions
import Spark.Core.StructuresInternal
import Spark.Core.Internal.FunctionsInternals(TupleEquivalence(..), NameTuple(..))
import Spark.Core.Try
castType :: forall a b. (SQLTypeable b) => SQLType a -> Try (SQLType b)
castType sqlt =
let sqlt' = buildType :: SQLType b in
if unSQLType sqlt == unSQLType sqlt' then Right sqlt'
else tryError $ sformat ("castType: tried to cast "%shown%" into incompatible type "%shown) sqlt sqlt'