summaryrefslogtreecommitdiff
path: root/lc
diff options
context:
space:
mode:
authorPéter Diviánszky <divipp@gmail.com>2016-01-19 11:56:05 +0100
committerPéter Diviánszky <divipp@gmail.com>2016-01-19 17:37:51 +0100
commit123447170ec2d85752f04a94b423babe7f2f490e (patch)
treecabd629f59fcc25756b555e23e3e99a80be79bd6 /lc
parenta0b8a8b0793dedd2d0cb06ac70c9dc2a426f8631 (diff)
move fromInt to Internals
Diffstat (limited to 'lc')
-rw-r--r--lc/Builtins.lc18
-rw-r--r--lc/Internals.lc19
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
109instance Signed Int 109instance Signed Int
110instance Signed Float 110instance Signed Float
111 111
112class Num a where
113 fromInt :: Int -> a
114 compare :: a -> a -> Ordering
115 negate :: a -> a
116
117instance Num Int where
118 fromInt = id
119 compare = primCompareInt
120 negate = primNegateInt
121instance Num Word where
122 fromInt = primIntToWord
123 compare = primCompareWord
124 negate = primNegateWord
125instance Num Float where
126 fromInt = primIntToFloat
127 compare = primCompareFloat
128 negate = primNegateFloat
129
130class Component a where 112class 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
59primIfThenElse True a b = a 59primIfThenElse True a b = a
60primIfThenElse False a b = b 60primIfThenElse False a b = b
61 61
62-- fromInt is needed for integer literal
63class Num a where
64 fromInt :: Int -> a
65 compare :: a -> a -> Ordering
66 negate :: a -> a
67
68instance Num Int where
69 fromInt = \x -> x
70 compare = primCompareInt
71 negate = primNegateInt
72instance Num Word where
73 fromInt = primIntToWord
74 compare = primCompareWord
75 negate = primNegateWord
76instance Num Float where
77 fromInt = primIntToFloat
78 compare = primCompareFloat
79 negate = primNegateFloat
80
62 81