Skip to content
This repository has been archived by the owner on Jan 31, 2020. It is now read-only.

Commit

Permalink
Remove unnecessary FFI
Browse files Browse the repository at this point in the history
  • Loading branch information
tfausak committed Dec 2, 2015
1 parent 5db1e4d commit e9f858c
Show file tree
Hide file tree
Showing 9 changed files with 7 additions and 51 deletions.
2 changes: 1 addition & 1 deletion src/Neon/Effects/Native/Exception.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module.exports = {
return x();
} catch (e) {
if (e instanceof Error) {
return f(x)();
return f(e)();
} else {
return f(new Error(e.toString()))();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Neon/Types/HasAdd.purs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ instance arrayHasAdd :: HasAdd (Array a) where
add x y = nativeAddArray x y

instance booleanHasAdd :: HasAdd Boolean where
add x y = nativeAddBoolean x y
add x y = if x then true else y

instance functionHasAdd :: (HasAdd b) => HasAdd (a -> b) where
add f g = \ x -> f x + g x
Expand Down
7 changes: 2 additions & 5 deletions src/Neon/Types/HasBottom.purs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ import Neon.Types.HasCompare (HasCompare)
import Neon.Types.HasSubtract (negate)
import Neon.Values.Ordering (Ordering(LessThan))

foreign import nativeBottomChar :: Char
foreign import nativeBottomInt :: Int

-- | Represents types that have a lower bound.
-- |
-- | Laws:
Expand All @@ -29,13 +26,13 @@ instance booleanHasBottom :: HasBottom Boolean where
bottom = false

instance charHasBottom :: HasBottom Char where
bottom = nativeBottomChar
bottom = '\0'

instance functionHasBottom :: (HasBottom b) => HasBottom (a -> b) where
bottom = always bottom

instance intHasBottom :: HasBottom Int where
bottom = nativeBottomInt
bottom = -2147483648

instance numberHasBottom :: HasBottom Number where
bottom = -infinity
Expand Down
2 changes: 1 addition & 1 deletion src/Neon/Types/HasMultiply.purs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class (HasZero a) <= HasMultiply a where
multiply :: a -> a -> a

instance booleanHasMultiply :: HasMultiply Boolean where
multiply x y = nativeMultiplyBoolean x y
multiply x y = if x then y else false

instance functionHasMultiply :: (HasMultiply b) => HasMultiply (a -> b) where
multiply f g = \ x -> f x * g x
Expand Down
7 changes: 2 additions & 5 deletions src/Neon/Types/HasTop.purs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ import Neon.Primitives.Number (infinity)
import Neon.Types.HasCompare (HasCompare)
import Neon.Values.Ordering (Ordering(GreaterThan))

foreign import nativeTopChar :: Char
foreign import nativeTopInt :: Int

-- | Represents types that have an upper bound.
-- |
-- | Laws:
Expand All @@ -28,13 +25,13 @@ instance booleanHasTop :: HasTop Boolean where
top = true

instance charHasTop :: HasTop Char where
top = nativeTopChar
top = '\65535'

instance functionHasTop :: (HasTop b) => HasTop (a -> b) where
top = always top

instance intHasTop :: HasTop Int where
top = nativeTopInt
top = 2147483647

instance numberHasTop :: HasTop Number where
top = infinity
Expand Down
10 changes: 0 additions & 10 deletions src/Neon/Types/Native/HasAdd.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,6 @@ module.exports = {
};
},

nativeAddBoolean: function (x) {
return function (y) {
if (x) {
return x;
} else {
return y;
}
};
},

nativeAddInt: addGeneric,

nativeAddNumber: addGeneric,
Expand Down
9 changes: 0 additions & 9 deletions src/Neon/Types/Native/HasBottom.js

This file was deleted.

10 changes: 0 additions & 10 deletions src/Neon/Types/Native/HasMultiply.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,6 @@ var multiplyGeneric = function (x) {
};

module.exports = {
nativeMultiplyBoolean: function (x) {
return function (y) {
if (x) {
return y;
} else {
return x;
}
};
},

nativeMultiplyInt: multiplyGeneric,

nativeMultiplyNumber: multiplyGeneric
Expand Down
9 changes: 0 additions & 9 deletions src/Neon/Types/Native/HasTop.js

This file was deleted.

0 comments on commit e9f858c

Please sign in to comment.