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

Add bottom & top instances for numbers #37

Merged
merged 2 commits into from
Nov 12, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/Neon/Types/HasBottom.purs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ module Neon.Types.HasBottom
) where

import Neon.Primitives.Function (constant)
import Neon.Primitives.Number (infinity)
import Neon.Types.HasCompare (HasCompare)
import Neon.Types.HasSubtract (negate)
import Neon.Values.Ordering (Ordering(LessThan))

foreign import nativeBottomChar :: Char
Expand All @@ -27,5 +29,8 @@ instance functionHasBottom :: (HasBottom b) => HasBottom (a -> b) where
instance intHasBottom :: HasBottom Int where
bottom = nativeBottomInt

instance numberHasBottom :: HasBottom Number where
bottom = negate infinity

instance orderingHasBottom :: HasBottom Ordering where
bottom = LessThan
4 changes: 4 additions & 0 deletions src/Neon/Types/HasTop.purs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module Neon.Types.HasTop
) where

import Neon.Primitives.Function (constant)
import Neon.Primitives.Number (infinity)
import Neon.Types.HasCompare (HasCompare)
import Neon.Values.Ordering (Ordering(GreaterThan))

Expand All @@ -27,5 +28,8 @@ instance functionHasTop :: (HasTop b) => HasTop (a -> b) where
instance intHasTop :: HasTop Int where
top = nativeTopInt

instance numberHasTop :: HasTop Number where
top = infinity

instance orderingHasTop :: HasTop Ordering where
top = GreaterThan
1 change: 1 addition & 0 deletions test/Neon/Types/HasBottom.purs
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ testHasBottom = do
-- bottom ==> '\0' -- NOTE: purescript/purescript#1602
bottom unit ==> false
bottom ==> 0 - 2147483648 -- NOTE: purescript/purescript#1591
bottom ==> negate infinity
bottom ==> LessThan
1 change: 1 addition & 0 deletions test/Neon/Types/HasTop.purs
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ testHasTop = do
top ==> '\65535'
top unit ==> true
top ==> 2147483647
top ==> infinity
top ==> GreaterThan