Skip to content

Commit 5e7ac0d

Browse files
committed
Use Nullable
1 parent d1c5a2b commit 5e7ac0d

File tree

2 files changed

+11
-15
lines changed

2 files changed

+11
-15
lines changed

src/Data/ArrayBuffer/DataView.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ exports.byteLength = function byteLength (v) {
2929

3030
exports.getterImpl = function getterImpl (data, v, o) {
3131
return ((o + data.bytesPerValue) >>> 0) <= v.byteLength
32-
? data.just (v[data.functionName].call(v,o,data.littleEndian))
33-
: data.nothing;
32+
? v[data.functionName].call(v,o,data.littleEndian)
33+
: null;
3434
};
3535

3636
exports.setterImpl = function setterImpl (data, v, o, n) {

src/Data/ArrayBuffer/DataView.purs

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,17 @@ module Data.ArrayBuffer.DataView
4848
, whole
4949
) where
5050

51-
import Prelude (class Eq, (==), (<>))
52-
5351
import Data.ArrayBuffer.Types (ArrayBuffer, ByteLength, ByteOffset, DataView, Float32, Float64, Int16, Int32, Int8, Uint16, Uint32, Uint8, Uint8Clamped, kind ArrayViewType)
5452
import Data.ArrayBuffer.ValueMapping (class BinaryValue, class BytesPerValue)
55-
import Data.Maybe (Maybe(..))
53+
import Data.Float32 (Float32) as F
54+
import Data.Maybe (Maybe)
55+
import Data.Nullable (Nullable, toMaybe)
56+
import Data.Symbol (SProxy(..), class IsSymbol, reflectSymbol)
5657
import Data.Typelevel.Num (toInt', class Nat)
5758
import Data.UInt (UInt)
58-
import Data.Float32 (Float32) as F
59-
import Data.Symbol (SProxy (..), class IsSymbol, reflectSymbol)
6059
import Effect (Effect)
6160
import Effect.Uncurried (EffectFn2, EffectFn3, EffectFn4, runEffectFn2, runEffectFn3, runEffectFn4)
61+
import Prelude (class Eq, (<$>), (<>), (==))
6262
import Type.Proxy (Proxy(..))
6363

6464

@@ -122,24 +122,20 @@ instance showArrayViewTypeViewFloat32 :: ShowArrayViewType Float32 "Float32"
122122
instance showArrayViewTypeViewFloat64 :: ShowArrayViewType Float64 "Float64"
123123

124124
foreign import getterImpl :: forall t
125-
. EffectFn3 { just :: t -> Maybe t
126-
, nothing :: Maybe t
127-
, functionName :: String
125+
. EffectFn3 { functionName :: String
128126
, littleEndian :: Boolean
129127
, bytesPerValue :: ByteLength
130-
} DataView ByteOffset (Maybe t)
128+
} DataView ByteOffset (Nullable t)
131129

132130
getter :: forall t.
133131
{ functionName :: String
134132
, bytesPerValue :: ByteLength
135133
, littleEndian :: Boolean
136134
}
137135
-> DataView -> ByteOffset -> Effect (Maybe t)
138-
getter data' d o =
136+
getter data' d o = toMaybe <$>
139137
runEffectFn3 getterImpl
140-
{ just: Just
141-
, nothing: Nothing
142-
, functionName: data'.functionName
138+
{ functionName: data'.functionName
143139
, littleEndian: data'.littleEndian
144140
, bytesPerValue: data'.bytesPerValue
145141
} d o

0 commit comments

Comments
 (0)