diff options
author | Péter Diviánszky <divipp@gmail.com> | 2016-01-19 11:56:05 +0100 |
---|---|---|
committer | Péter Diviánszky <divipp@gmail.com> | 2016-01-19 17:37:51 +0100 |
commit | 123447170ec2d85752f04a94b423babe7f2f490e (patch) | |
tree | cabd629f59fcc25756b555e23e3e99a80be79bd6 /lc | |
parent | a0b8a8b0793dedd2d0cb06ac70c9dc2a426f8631 (diff) |
move fromInt to Internals
Diffstat (limited to 'lc')
-rw-r--r-- | lc/Builtins.lc | 18 | ||||
-rw-r--r-- | lc/Internals.lc | 19 |
2 files changed, 19 insertions, 18 deletions
diff --git a/lc/Builtins.lc b/lc/Builtins.lc index 1d10d532..47dfc4e1 100644 --- a/lc/Builtins.lc +++ b/lc/Builtins.lc | |||
@@ -109,24 +109,6 @@ class Signed a | |||
109 | instance Signed Int | 109 | instance Signed Int |
110 | instance Signed Float | 110 | instance Signed Float |
111 | 111 | ||
112 | class Num a where | ||
113 | fromInt :: Int -> a | ||
114 | compare :: a -> a -> Ordering | ||
115 | negate :: a -> a | ||
116 | |||
117 | instance Num Int where | ||
118 | fromInt = id | ||
119 | compare = primCompareInt | ||
120 | negate = primNegateInt | ||
121 | instance Num Word where | ||
122 | fromInt = primIntToWord | ||
123 | compare = primCompareWord | ||
124 | negate = primNegateWord | ||
125 | instance Num Float where | ||
126 | fromInt = primIntToFloat | ||
127 | compare = primCompareFloat | ||
128 | negate = primNegateFloat | ||
129 | |||
130 | class Component a where | 112 | class Component a where |
131 | vec2 :: a -> a -> Vec 2 a | 113 | vec2 :: a -> a -> Vec 2 a |
132 | vec3 :: a -> a -> a -> Vec 3 a | 114 | vec3 :: a -> a -> a -> Vec 3 a |
diff --git a/lc/Internals.lc b/lc/Internals.lc index d3f6ed84..5d5a38b1 100644 --- a/lc/Internals.lc +++ b/lc/Internals.lc | |||
@@ -59,4 +59,23 @@ primIfThenElse :: Bool -> a -> a -> a | |||
59 | primIfThenElse True a b = a | 59 | primIfThenElse True a b = a |
60 | primIfThenElse False a b = b | 60 | primIfThenElse False a b = b |
61 | 61 | ||
62 | -- fromInt is needed for integer literal | ||
63 | class Num a where | ||
64 | fromInt :: Int -> a | ||
65 | compare :: a -> a -> Ordering | ||
66 | negate :: a -> a | ||
67 | |||
68 | instance Num Int where | ||
69 | fromInt = \x -> x | ||
70 | compare = primCompareInt | ||
71 | negate = primNegateInt | ||
72 | instance Num Word where | ||
73 | fromInt = primIntToWord | ||
74 | compare = primCompareWord | ||
75 | negate = primNegateWord | ||
76 | instance Num Float where | ||
77 | fromInt = primIntToFloat | ||
78 | compare = primCompareFloat | ||
79 | negate = primNegateFloat | ||
80 | |||
62 | 81 | ||