2021-01-26 06:58:35 +03:00
|
|
|
module Prelude.Cast
|
|
|
|
|
|
|
|
import Prelude.Basics
|
|
|
|
import Prelude.Num
|
|
|
|
import Prelude.Types
|
|
|
|
|
2021-06-09 01:05:10 +03:00
|
|
|
%default total
|
|
|
|
|
2021-01-26 06:58:35 +03:00
|
|
|
-----------
|
|
|
|
-- CASTS --
|
|
|
|
-----------
|
|
|
|
|
|
|
|
-- Casts between primitives only here. They might be lossy.
|
|
|
|
|
|
|
|
||| Interface for transforming an instance of a data type to another type.
|
|
|
|
public export
|
|
|
|
interface Cast from to where
|
2021-05-06 18:32:51 +03:00
|
|
|
constructor MkCast
|
2021-01-26 06:58:35 +03:00
|
|
|
||| Perform a (potentially lossy!) cast operation.
|
|
|
|
||| @ orig The original type
|
|
|
|
cast : (orig : from) -> to
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-04-25 11:22:01 +03:00
|
|
|
Cast a a where
|
|
|
|
cast = id
|
|
|
|
|
2021-01-26 06:58:35 +03:00
|
|
|
-- To String
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-01-26 06:58:35 +03:00
|
|
|
Cast Int String where
|
|
|
|
cast = prim__cast_IntString
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-01-26 06:58:35 +03:00
|
|
|
Cast Integer String where
|
|
|
|
cast = prim__cast_IntegerString
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-01-26 06:58:35 +03:00
|
|
|
Cast Char String where
|
|
|
|
cast = prim__cast_CharString
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-01-26 06:58:35 +03:00
|
|
|
Cast Double String where
|
|
|
|
cast = prim__cast_DoubleString
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Nat String where
|
|
|
|
cast = cast . natToInteger
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Int8 String where
|
|
|
|
cast = prim__cast_Int8String
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Int16 String where
|
|
|
|
cast = prim__cast_Int16String
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Int32 String where
|
|
|
|
cast = prim__cast_Int32String
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Int64 String where
|
|
|
|
cast = prim__cast_Int64String
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Bits8 String where
|
|
|
|
cast = prim__cast_Bits8String
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Bits16 String where
|
|
|
|
cast = prim__cast_Bits16String
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Bits32 String where
|
|
|
|
cast = prim__cast_Bits32String
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Bits64 String where
|
|
|
|
cast = prim__cast_Bits64String
|
|
|
|
|
2021-01-26 06:58:35 +03:00
|
|
|
-- To Integer
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-01-26 06:58:35 +03:00
|
|
|
Cast Int Integer where
|
|
|
|
cast = prim__cast_IntInteger
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-01-26 06:58:35 +03:00
|
|
|
Cast Char Integer where
|
|
|
|
cast = prim__cast_CharInteger
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-01-26 06:58:35 +03:00
|
|
|
Cast Double Integer where
|
|
|
|
cast = prim__cast_DoubleInteger
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-01-26 06:58:35 +03:00
|
|
|
Cast String Integer where
|
|
|
|
cast = prim__cast_StringInteger
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-01-26 06:58:35 +03:00
|
|
|
Cast Nat Integer where
|
|
|
|
cast = natToInteger
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-01-26 06:58:35 +03:00
|
|
|
Cast Bits8 Integer where
|
|
|
|
cast = prim__cast_Bits8Integer
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-01-26 06:58:35 +03:00
|
|
|
Cast Bits16 Integer where
|
|
|
|
cast = prim__cast_Bits16Integer
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-01-26 06:58:35 +03:00
|
|
|
Cast Bits32 Integer where
|
|
|
|
cast = prim__cast_Bits32Integer
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-01-26 06:58:35 +03:00
|
|
|
Cast Bits64 Integer where
|
|
|
|
cast = prim__cast_Bits64Integer
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Int8 Integer where
|
|
|
|
cast = prim__cast_Int8Integer
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Int16 Integer where
|
|
|
|
cast = prim__cast_Int16Integer
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Int32 Integer where
|
|
|
|
cast = prim__cast_Int32Integer
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Int64 Integer where
|
|
|
|
cast = prim__cast_Int64Integer
|
|
|
|
|
2021-01-26 06:58:35 +03:00
|
|
|
-- To Int
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-01-26 06:58:35 +03:00
|
|
|
Cast Integer Int where
|
|
|
|
cast = prim__cast_IntegerInt
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-01-26 06:58:35 +03:00
|
|
|
Cast Char Int where
|
|
|
|
cast = prim__cast_CharInt
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-01-26 06:58:35 +03:00
|
|
|
Cast Double Int where
|
|
|
|
cast = prim__cast_DoubleInt
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-01-26 06:58:35 +03:00
|
|
|
Cast String Int where
|
|
|
|
cast = prim__cast_StringInt
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-01-26 06:58:35 +03:00
|
|
|
Cast Nat Int where
|
|
|
|
cast = fromInteger . natToInteger
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-01-26 06:58:35 +03:00
|
|
|
Cast Bits8 Int where
|
|
|
|
cast = prim__cast_Bits8Int
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-01-26 06:58:35 +03:00
|
|
|
Cast Bits16 Int where
|
|
|
|
cast = prim__cast_Bits16Int
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-01-26 06:58:35 +03:00
|
|
|
Cast Bits32 Int where
|
|
|
|
cast = prim__cast_Bits32Int
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-01-26 06:58:35 +03:00
|
|
|
Cast Bits64 Int where
|
|
|
|
cast = prim__cast_Bits64Int
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Int8 Int where
|
|
|
|
cast = prim__cast_Int8Int
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Int16 Int where
|
|
|
|
cast = prim__cast_Int16Int
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Int32 Int where
|
|
|
|
cast = prim__cast_Int32Int
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Int64 Int where
|
|
|
|
cast = prim__cast_Int64Int
|
|
|
|
|
2021-01-26 06:58:35 +03:00
|
|
|
-- To Char
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-01-26 06:58:35 +03:00
|
|
|
Cast Int Char where
|
|
|
|
cast = prim__cast_IntChar
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Integer Char where
|
|
|
|
cast = prim__cast_IntegerChar
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Nat Char where
|
|
|
|
cast = cast . natToInteger
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Bits8 Char where
|
|
|
|
cast = prim__cast_Bits8Char
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Bits16 Char where
|
|
|
|
cast = prim__cast_Bits16Char
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Bits32 Char where
|
|
|
|
cast = prim__cast_Bits32Char
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Bits64 Char where
|
|
|
|
cast = prim__cast_Bits64Char
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Int8 Char where
|
|
|
|
cast = prim__cast_Int8Char
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Int16 Char where
|
|
|
|
cast = prim__cast_Int16Char
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Int32 Char where
|
|
|
|
cast = prim__cast_Int32Char
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Int64 Char where
|
|
|
|
cast = prim__cast_Int64Char
|
|
|
|
|
2021-01-26 06:58:35 +03:00
|
|
|
-- To Double
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-01-26 06:58:35 +03:00
|
|
|
Cast Int Double where
|
|
|
|
cast = prim__cast_IntDouble
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-01-26 06:58:35 +03:00
|
|
|
Cast Integer Double where
|
|
|
|
cast = prim__cast_IntegerDouble
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-01-26 06:58:35 +03:00
|
|
|
Cast String Double where
|
|
|
|
cast = prim__cast_StringDouble
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-01-26 06:58:35 +03:00
|
|
|
Cast Nat Double where
|
|
|
|
cast = prim__cast_IntegerDouble . natToInteger
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Bits8 Double where
|
|
|
|
cast = prim__cast_Bits8Double
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Bits16 Double where
|
|
|
|
cast = prim__cast_Bits16Double
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Bits32 Double where
|
|
|
|
cast = prim__cast_Bits32Double
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Bits64 Double where
|
|
|
|
cast = prim__cast_Bits64Double
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Int8 Double where
|
|
|
|
cast = prim__cast_Int8Double
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Int16 Double where
|
|
|
|
cast = prim__cast_Int16Double
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Int32 Double where
|
|
|
|
cast = prim__cast_Int32Double
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Int64 Double where
|
|
|
|
cast = prim__cast_Int64Double
|
|
|
|
|
2021-01-26 06:58:35 +03:00
|
|
|
|
|
|
|
-- To Bits8
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-01-26 06:58:35 +03:00
|
|
|
Cast Int Bits8 where
|
|
|
|
cast = prim__cast_IntBits8
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-01-26 06:58:35 +03:00
|
|
|
Cast Integer Bits8 where
|
|
|
|
cast = prim__cast_IntegerBits8
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-01-26 06:58:35 +03:00
|
|
|
Cast Bits16 Bits8 where
|
|
|
|
cast = prim__cast_Bits16Bits8
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-01-26 06:58:35 +03:00
|
|
|
Cast Bits32 Bits8 where
|
|
|
|
cast = prim__cast_Bits32Bits8
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-01-26 06:58:35 +03:00
|
|
|
Cast Bits64 Bits8 where
|
|
|
|
cast = prim__cast_Bits64Bits8
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast String Bits8 where
|
|
|
|
cast = prim__cast_StringBits8
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Double Bits8 where
|
|
|
|
cast = prim__cast_DoubleBits8
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Char Bits8 where
|
|
|
|
cast = prim__cast_CharBits8
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Nat Bits8 where
|
|
|
|
cast = cast . natToInteger
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Int8 Bits8 where
|
|
|
|
cast = prim__cast_Int8Bits8
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Int16 Bits8 where
|
|
|
|
cast = prim__cast_Int16Bits8
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Int32 Bits8 where
|
|
|
|
cast = prim__cast_Int32Bits8
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Int64 Bits8 where
|
|
|
|
cast = prim__cast_Int64Bits8
|
|
|
|
|
2021-01-26 06:58:35 +03:00
|
|
|
|
|
|
|
-- To Bits16
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-01-26 06:58:35 +03:00
|
|
|
Cast Int Bits16 where
|
|
|
|
cast = prim__cast_IntBits16
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-01-26 06:58:35 +03:00
|
|
|
Cast Integer Bits16 where
|
|
|
|
cast = prim__cast_IntegerBits16
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-01-26 06:58:35 +03:00
|
|
|
Cast Bits8 Bits16 where
|
|
|
|
cast = prim__cast_Bits8Bits16
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-01-26 06:58:35 +03:00
|
|
|
Cast Bits32 Bits16 where
|
|
|
|
cast = prim__cast_Bits32Bits16
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-01-26 06:58:35 +03:00
|
|
|
Cast Bits64 Bits16 where
|
|
|
|
cast = prim__cast_Bits64Bits16
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast String Bits16 where
|
|
|
|
cast = prim__cast_StringBits16
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Double Bits16 where
|
|
|
|
cast = prim__cast_DoubleBits16
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Char Bits16 where
|
|
|
|
cast = prim__cast_CharBits16
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Nat Bits16 where
|
|
|
|
cast = cast . natToInteger
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Int8 Bits16 where
|
|
|
|
cast = prim__cast_Int8Bits16
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Int16 Bits16 where
|
|
|
|
cast = prim__cast_Int16Bits16
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Int32 Bits16 where
|
|
|
|
cast = prim__cast_Int32Bits16
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Int64 Bits16 where
|
|
|
|
cast = prim__cast_Int64Bits16
|
|
|
|
|
2021-01-26 06:58:35 +03:00
|
|
|
|
|
|
|
-- To Bits32
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-01-26 06:58:35 +03:00
|
|
|
Cast Int Bits32 where
|
|
|
|
cast = prim__cast_IntBits32
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-01-26 06:58:35 +03:00
|
|
|
Cast Integer Bits32 where
|
|
|
|
cast = prim__cast_IntegerBits32
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-01-26 06:58:35 +03:00
|
|
|
Cast Bits8 Bits32 where
|
|
|
|
cast = prim__cast_Bits8Bits32
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-01-26 06:58:35 +03:00
|
|
|
Cast Bits16 Bits32 where
|
|
|
|
cast = prim__cast_Bits16Bits32
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-01-26 06:58:35 +03:00
|
|
|
Cast Bits64 Bits32 where
|
|
|
|
cast = prim__cast_Bits64Bits32
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast String Bits32 where
|
|
|
|
cast = prim__cast_StringBits32
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Double Bits32 where
|
|
|
|
cast = prim__cast_DoubleBits32
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Char Bits32 where
|
|
|
|
cast = prim__cast_CharBits32
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Nat Bits32 where
|
|
|
|
cast = cast . natToInteger
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Int8 Bits32 where
|
|
|
|
cast = prim__cast_Int8Bits32
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Int16 Bits32 where
|
|
|
|
cast = prim__cast_Int16Bits32
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Int32 Bits32 where
|
|
|
|
cast = prim__cast_Int32Bits32
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Int64 Bits32 where
|
|
|
|
cast = prim__cast_Int64Bits32
|
|
|
|
|
2021-01-26 06:58:35 +03:00
|
|
|
-- To Bits64
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-01-26 06:58:35 +03:00
|
|
|
Cast Int Bits64 where
|
|
|
|
cast = prim__cast_IntBits64
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-01-26 06:58:35 +03:00
|
|
|
Cast Integer Bits64 where
|
|
|
|
cast = prim__cast_IntegerBits64
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-01-26 06:58:35 +03:00
|
|
|
Cast Bits8 Bits64 where
|
|
|
|
cast = prim__cast_Bits8Bits64
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-01-26 06:58:35 +03:00
|
|
|
Cast Bits16 Bits64 where
|
|
|
|
cast = prim__cast_Bits16Bits64
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-01-26 06:58:35 +03:00
|
|
|
Cast Bits32 Bits64 where
|
|
|
|
cast = prim__cast_Bits32Bits64
|
2021-06-28 22:00:10 +03:00
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast String Bits64 where
|
|
|
|
cast = prim__cast_StringBits64
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Double Bits64 where
|
|
|
|
cast = prim__cast_DoubleBits64
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Char Bits64 where
|
|
|
|
cast = prim__cast_CharBits64
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Nat Bits64 where
|
|
|
|
cast = cast . natToInteger
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Int8 Bits64 where
|
|
|
|
cast = prim__cast_Int8Bits64
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Int16 Bits64 where
|
|
|
|
cast = prim__cast_Int16Bits64
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Int32 Bits64 where
|
|
|
|
cast = prim__cast_Int32Bits64
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Int64 Bits64 where
|
|
|
|
cast = prim__cast_Int64Bits64
|
|
|
|
|
|
|
|
-- To Int8
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast String Int8 where
|
|
|
|
cast = prim__cast_StringInt8
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Double Int8 where
|
|
|
|
cast = prim__cast_DoubleInt8
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Char Int8 where
|
|
|
|
cast = prim__cast_CharInt8
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Int Int8 where
|
|
|
|
cast = prim__cast_IntInt8
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Integer Int8 where
|
|
|
|
cast = prim__cast_IntegerInt8
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Nat Int8 where
|
|
|
|
cast = cast . natToInteger
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Bits8 Int8 where
|
|
|
|
cast = prim__cast_Bits8Int8
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Bits16 Int8 where
|
|
|
|
cast = prim__cast_Bits16Int8
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Bits32 Int8 where
|
|
|
|
cast = prim__cast_Bits32Int8
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Bits64 Int8 where
|
|
|
|
cast = prim__cast_Bits64Int8
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Int16 Int8 where
|
|
|
|
cast = prim__cast_Int16Int8
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Int32 Int8 where
|
|
|
|
cast = prim__cast_Int32Int8
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Int64 Int8 where
|
|
|
|
cast = prim__cast_Int64Int8
|
|
|
|
|
|
|
|
-- To Int16
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast String Int16 where
|
|
|
|
cast = prim__cast_StringInt16
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Double Int16 where
|
|
|
|
cast = prim__cast_DoubleInt16
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Char Int16 where
|
|
|
|
cast = prim__cast_CharInt16
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Int Int16 where
|
|
|
|
cast = prim__cast_IntInt16
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Integer Int16 where
|
|
|
|
cast = prim__cast_IntegerInt16
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Nat Int16 where
|
|
|
|
cast = cast . natToInteger
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Bits8 Int16 where
|
|
|
|
cast = prim__cast_Bits8Int16
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Bits16 Int16 where
|
|
|
|
cast = prim__cast_Bits16Int16
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Bits32 Int16 where
|
|
|
|
cast = prim__cast_Bits32Int16
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Bits64 Int16 where
|
|
|
|
cast = prim__cast_Bits64Int16
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Int8 Int16 where
|
|
|
|
cast = prim__cast_Int8Int16
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Int32 Int16 where
|
|
|
|
cast = prim__cast_Int32Int16
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Int64 Int16 where
|
|
|
|
cast = prim__cast_Int64Int16
|
|
|
|
|
|
|
|
-- To Int32
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast String Int32 where
|
|
|
|
cast = prim__cast_StringInt32
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Double Int32 where
|
|
|
|
cast = prim__cast_DoubleInt32
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Char Int32 where
|
|
|
|
cast = prim__cast_CharInt32
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Int Int32 where
|
|
|
|
cast = prim__cast_IntInt32
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Integer Int32 where
|
|
|
|
cast = prim__cast_IntegerInt32
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Nat Int32 where
|
|
|
|
cast = cast . natToInteger
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Bits8 Int32 where
|
|
|
|
cast = prim__cast_Bits8Int32
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Bits16 Int32 where
|
|
|
|
cast = prim__cast_Bits16Int32
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Bits32 Int32 where
|
|
|
|
cast = prim__cast_Bits32Int32
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Bits64 Int32 where
|
|
|
|
cast = prim__cast_Bits64Int32
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Int8 Int32 where
|
|
|
|
cast = prim__cast_Int8Int32
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Int16 Int32 where
|
|
|
|
cast = prim__cast_Int16Int32
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Int64 Int32 where
|
|
|
|
cast = prim__cast_Int64Int32
|
|
|
|
|
|
|
|
-- To Int64
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast String Int64 where
|
|
|
|
cast = prim__cast_StringInt64
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Double Int64 where
|
|
|
|
cast = prim__cast_DoubleInt64
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Char Int64 where
|
|
|
|
cast = prim__cast_CharInt64
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Int Int64 where
|
|
|
|
cast = prim__cast_IntInt64
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Integer Int64 where
|
|
|
|
cast = prim__cast_IntegerInt64
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Nat Int64 where
|
|
|
|
cast = cast . natToInteger
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Bits8 Int64 where
|
|
|
|
cast = prim__cast_Bits8Int64
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Bits16 Int64 where
|
|
|
|
cast = prim__cast_Bits16Int64
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Bits32 Int64 where
|
|
|
|
cast = prim__cast_Bits32Int64
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Bits64 Int64 where
|
|
|
|
cast = prim__cast_Bits64Int64
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Int8 Int64 where
|
|
|
|
cast = prim__cast_Int8Int64
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Int16 Int64 where
|
|
|
|
cast = prim__cast_Int16Int64
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Int32 Int64 where
|
|
|
|
cast = prim__cast_Int32Int64
|
|
|
|
|
|
|
|
-- To Nat
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast String Nat where
|
|
|
|
cast = integerToNat . cast
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Double Nat where
|
|
|
|
cast = integerToNat . cast
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Char Nat where
|
2021-08-25 13:00:07 +03:00
|
|
|
cast = integerToNat . cast {to = Integer}
|
2021-06-28 22:00:10 +03:00
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Int Nat where
|
|
|
|
cast = integerToNat . cast
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Integer Nat where
|
|
|
|
cast = integerToNat
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Bits8 Nat where
|
2021-08-25 13:00:07 +03:00
|
|
|
cast = integerToNat . cast {to = Integer}
|
2021-06-28 22:00:10 +03:00
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Bits16 Nat where
|
2021-08-25 13:00:07 +03:00
|
|
|
cast = integerToNat . cast {to = Integer}
|
2021-06-28 22:00:10 +03:00
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Bits32 Nat where
|
2021-08-25 13:00:07 +03:00
|
|
|
cast = integerToNat . cast {to = Integer}
|
2021-06-28 22:00:10 +03:00
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Bits64 Nat where
|
2021-08-25 13:00:07 +03:00
|
|
|
cast = integerToNat . cast {to = Integer}
|
2021-06-28 22:00:10 +03:00
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Int8 Nat where
|
|
|
|
cast = integerToNat . cast
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Int16 Nat where
|
|
|
|
cast = integerToNat . cast
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Int32 Nat where
|
|
|
|
cast = integerToNat . cast
|
|
|
|
|
2022-09-21 12:05:02 +03:00
|
|
|
export %inline
|
2021-06-28 22:00:10 +03:00
|
|
|
Cast Int64 Nat where
|
|
|
|
cast = integerToNat . cast
|