2 import "JavaBuiltin" as Java
4 class Coercible a b where
7 //instance Coercible a a where
10 instance (Coercible a b) => Coercible [a] [b] where
15 instance Coercible Byte Integer where
18 instance Coercible Byte Long where
19 coerce = Java.i2l . Java.b2i
23 instance Coercible Character Integer where
26 instance Coercible Character Long where
27 coerce = Java.i2l . Java.c2i
31 instance Coercible Short Integer where
34 instance Coercible Short Long where
35 coerce = Java.i2l . Java.s2i
39 instance Coercible Integer Byte where
42 instance Coercible Integer Character where
45 instance Coercible Integer Short where
48 instance Coercible Integer Long where
51 instance Coercible Integer Float where
54 instance Coercible Integer Double where
57 instance Coercible Integer String where
58 coerce = coerceIntegerToString
62 instance Coercible Long Byte where
63 coerce = Java.i2b . Java.l2i
65 instance Coercible Long Character where
66 coerce = Java.i2c . Java.l2i
68 instance Coercible Long Short where
69 coerce = Java.i2s . Java.l2i
71 instance Coercible Long Integer where
74 instance Coercible Long Float where
77 instance Coercible Long Double where
80 instance Coercible Long String where
81 coerce = coerceLongToString
85 instance Coercible Float Byte where
86 coerce = Java.i2b . Java.f2i
88 instance Coercible Float Short where
89 coerce = Java.i2s . Java.f2i
91 instance Coercible Float Integer where
94 instance Coercible Float Long where
97 instance Coercible Float Double where
100 instance Coercible Float String where
101 coerce = coerceFloatToString
105 instance Coercible Double Byte where
106 coerce = Java.i2b . Java.d2i
108 instance Coercible Double Short where
109 coerce = Java.i2s . Java.d2i
111 instance Coercible Double Integer where
114 instance Coercible Double Long where
117 instance Coercible Double Float where
120 instance Coercible Double String where
121 coerce = coerceDoubleToString
125 instance Coercible String Integer where
126 coerce = coerceStringToInteger
128 instance Coercible String Long where
129 coerce = coerceStringToLong
131 instance Coercible String Float where
132 coerce = coerceStringToFloat
134 instance Coercible String Double where
135 coerce = coerceStringToDouble
140 importJava "java.lang.Integer" where
142 coerceIntegerToString :: Integer -> String
144 coerceStringToInteger :: String -> Integer
147 importJava "java.lang.Long" where
149 coerceLongToString :: Long -> String
151 coerceStringToLong :: String -> Long
154 importJava "java.lang.Float" where
156 coerceFloatToString :: Float -> String
158 coerceStringToFloat :: String -> Float
161 importJava "java.lang.Double" where
163 coerceDoubleToString :: Double -> String
164 @JavaName parseDouble
165 coerceStringToDouble :: String -> Double