-
Notifications
You must be signed in to change notification settings - Fork 70
/
source
1753 lines (1276 loc) · 29.2 KB
/
source
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
asTypeIn
a `asTypeIn` f = a where _ = f a
infixl 0 `asTypeIn`
asAppliedTo
f `asAppliedTo` a = f where _ = f a
infixl 0 `asAppliedTo`
Mu
newtype Mu f = In { out :: f (Mu f) }
In
newtype Mu f = In { out :: f (Mu f) }
out
newtype Mu f = In { out :: f (Mu f) }
Rec
newtype Rec a = InR { outR :: Rec a -> a }
InR
newtype Rec a = InR { outR :: Rec a -> a }
outR
newtype Rec a = InR { outR :: Rec a -> a }
(=<<)
f =<< x = x >>= f
Reader
type Reader r = ReaderT r Identity
--OR
data Reader r a = Reader { runReader :: r -> a }
Reader return
return a = Reader $ \_ -> a
Reader (>>=)
m >>= k = Reader $ \r ->
let a = runReader m r
in runReader (k a) r
Writer
type Writer w = WriterT w Identity
--OR
data Writer w a = Writer { runWriter :: (a, w) }
Writer return
return a = Writer (a, mempty)
Writer (>>=)
m >>= k = Writer $
let (a, w) = runWriter m
(b, w') = runWriter (k a)
in (b, w <> w')
State
type State s = StateT s Identity
--OR
data State s a = State { runState :: s -> (a, s) }
State return
return a = State $ \s -> (a, s)
State (>>=)
m >>= k = State $ \s ->
let (a, s') = runState m s
in runState (k a) s'
sequence
sequence [] = return []
sequence (x:xs) = do v <- x; vs <- sequence xs; return (v:vs)
--OR
sequence xs = foldr (liftM2 (:)) (return []) xs
sequence_
sequence_ ms = foldr (>>) (return ()) ms
mapM
mapM f as = sequence (map f as)
mapM_
mapM_ f as = sequence_ (map f as)
guard
guard True = pure ()
guard False = empty
forM
forM = flip mapM
forM_
forM_ = flip mapM_
msum
msum = foldr mplus mzero
join
join x = x >>= id
forever
forever a = let a' = a >> a' in a'
void
void = fmap (const ())
mapAndUnzipM
mapAndUnzipM f xs = sequence (map f xs) >>= return . unzip
zipWithM
zipWithM f xs ys = sequence (zipWith f xs ys)
zipWithM_
zipWithM_ f xs ys = sequence_ (zipWith f xs ys)
foldM
foldM _ a [] = return a
foldM f a (x:xs) = f a x >>= \fax -> foldM f fax xs
foldM_
foldM_ f a xs = foldM f a xs >> return ()
replicateM
replicateM n x = sequence (replicate n x)
replicateM_
replicateM_ n x = sequence_ (replicate n x)
when
when p s = if p then s else return ()
unless
unless p s = if p then return () else s
liftM
liftM f m1 = do
x1 <- m1
return (f x1)
liftM2
liftM2 f m1 m2 = do
x1 <- m1
x2 <- m2
return (f x1 x2)
liftM3
liftM3 f m1 m2 m3 = do
x1 <- m1
x2 <- m2
x3 <- m3
return (f x1 x2 x3)
liftM4
liftM4 f m1 m2 m3 m4 = do
x1 <- m1
x2 <- m2
x3 <- m3
x4 <- m4
return (f x1 x2 x3 x4)
ap
ap = liftM2 id
(>>)
m >> k = m >>= \_ -> k
fail
fail s = error s
compare
compare x y | x == y = EQ
| x <= y = LT
| otherwise = GT
comparing
comparing p x y = compare (p x) (p y)
(/=)
x /= y = not (x == y)
(==)
x == y = not (x /= y)
(<)
x < y = case compare x y of
LT -> True
_ -> False
(<=)
x <= y = case compare x y of
GT -> False
_ -> True
(>)
x > y = case compare x y of
GT -> True
_ -> False
(>=)
x >= y = case compare x y of
LT -> False
_ -> True
max
max x y = if x <= y then y else x
min
min x y = if x <= y then x else y
[]
data [] a = [] | a : [a]
foldr
foldr f z [] = z
foldr f z (x:xs) = f x (foldr f z xs)
build
build g = g (:) []
augment
augment g xs = g (:) xs
map
map _ [] = []
map f (x:xs) = f x : map f xs
(++)
[] ++ ys = ys
(x:xs) ++ ys = x : (xs ++ ys)
-- OR
xs ++ ys = foldr (:) ys xs
Bool
data Bool = False | True deriving (Eq, Ord)
(&&)
True && x = x
False && _ = False
(||)
True || _ = True
False || x = x
not
not True = False
not False = True
otherwise
otherwise = True
bool
bool f _ False = f
bool _ t True = t
()
data () = ()
Ordering
data Ordering = LT | EQ | GT
String
type String = [Char]
Char
data Char = C# Char#
Int
data Int = I# Int#
id
id x = x
const
const x _ = x
(.)
(f . g) x = f (g x)
flip
flip f x y = f y x
($)
f $ x = f x
($!)
f $! x = x `seq` f x
until
until p f x | p x = x
| otherwise = until p f (f x)
asTypeOf
asTypeOf = const
head
head (x:_) = x
head [] = error "Prelude.head: empty list"
tail
tail (_:xs) = xs
tail [] = error "Prelude.tail: empty list"
last
last [x] = x
last (_:xs) = last xs
last [] = error "Prelude.last: empty list"
init
init [x] = []
init (x:xs) = x : init xs
init [] = error "Prelude.init: empty list"
null
null [] = True
null (_:_) = False
filter
filter _ [] = []
filter p (x:xs)
| p x = x : filter p xs
| otherwise = filter p xs
foldl
foldl f z [] = z
foldl f z (x:xs) = foldl f (f z x) xs
scanr
scanr _ q0 [] = [q0]
scanr f q0 (x:xs) = f x q : qs
where qs@(q:_) = scanr f q0 xs
iterate
iterate f x = x : iterate f (f x)
repeat
repeat x = xs where xs = x : xs
replicate
replicate n x = take n (repeat x)
cycle
cycle [] = undefined
cycle xs = xs' where xs' = xs ++ xs'
takeWhile
takeWhile _ [] = []
takeWhile p (x:xs) | p x = x : takeWhile p xs
| otherwise = []
take
take n _ | n <= 0 = []
take _ [] = []
take n (x:xs) = x : take (n-1) xs
dropWhile
dropWhile _ [] = []
dropWhile p (x:xs) | p x = dropWhile p xs
| otherwise = x:xs
drop
drop n xs | n <= 0 = xs
drop _ [] = []
drop n (_:xs) = drop (n-1) xs
stripPrefix
stripPrefix [] ys = Just ys
stripPrefix (x:xs) (y:ys) | x == y = stripPrefix xs ys
stripPrefix _ _ = Nothing
splitAt
splitAt n xs = (take n xs, drop n xs)
break
break p = span (not . p)
span
span _ xs@[] = (xs, xs)
span p xs@(x:xs') | p x = let (ys,zs) = span p xs' in (x:ys,zs)
| otherwise = ([],xs)
reverse
reverse = foldl (flip (:)) []
and
and = foldr (&&) True
or
or = foldr (||) False
any
any p = or . map p
all
all p = and . map p
elem
elem x = any (== x)
notElem
notElem x = all (/= x)
lookup
lookup _key [] = Nothing
lookup key ((x,y):xys) | key == x = Just y
| otherwise = lookup key xys
concatMap
concatMap f = foldr ((++) . f) []
concat
concat = foldr (++) []
(!!)
xs !! n | n < 0 = undefined
[] !! _ = undefined
(x:_) !! 0 = x
(_:xs) !! n = xs !! (n-1)
zip
zip (a:as) (b:bs) = (a,b) : zip as bs
zip _ _ = []
zip3
zip3 (a:as) (b:bs) (c:cs) = (a,b,c) : zip3 as bs cs
zip3 _ _ _ = []
zipWith
zipWith f (a:as) (b:bs) = f a b : zipWith f as bs
zipWith _ _ _ = []
unzip
unzip = foldr (\(a,b) ~(as,bs) -> (a:as,b:bs)) ([],[])
elemIndex
elemIndex x = findIndex (x==)
elemIndices
elemIndices x = findIndices (x==)
find
find p = listToMaybe . filter p
findIndex
findIndex p = listToMaybe . findIndices p
findIndices
findIndices p xs = [ i | (x,i) <- zip xs [0..], p x]
isPrefixOf
isPrefixOf [] _ = True
isPrefixOf _ [] = False
isPrefixOf (x:xs) (y:ys) = x == y && isPrefixOf xs ys
isSuffixOf
isSuffixOf x y = reverse x `isPrefixOf` reverse y
isInfixOf
isInfixOf needle haystack = any (isPrefixOf needle) (tails haystack)
nub
nub = nubBy (==)
--OR
nub l = go l []
where go [] _ = []
go (x:xs) ls
| x `elem` ls = go xs ls
| otherwise = x : go xs (x:ls)
nubBy
nubBy eq [] = []
nubBy eq (x:xs) = x : nubBy eq (filter (\ y -> not (eq x y)) xs)
delete
delete = deleteBy (==)
deleteBy
deleteBy eq x [] = []
deleteBy eq x (y:ys) = if x `eq` y then ys else y : deleteBy eq x ys
(\\)
(\\) = foldl (flip delete)
union
union = unionBy (==)
unionBy
unionBy eq xs ys = xs ++ foldl (flip (deleteBy eq)) (nubBy eq ys) xs
intersect
intersect = intersectBy (==)
intersectBy
intersectBy eq xs ys = [x | x <- xs, any (eq x) ys]
intersperse
intersperse _ [] = []
intersperse _ [x] = [x]
intersperse sep (x:xs) = x : sep : intersperse sep xs
intercalate
intercalate xs xss = concat (intersperse xs xss)
transpose
transpose [] = []
transpose ([] : xss) = transpose xss
transpose ((x:xs) : xss) = (x : [h | (h:t) <- xss]) : transpose (xs : [ t | (h:t) <- xss])
partition
partition p xs = foldr (select p) ([],[]) xs
where select p x ~(ts,fs) | p x = (x:ts,fs)
| otherwise = (ts, x:fs)
mapAccumL
mapAccumL _ s [] = (s, [])
mapAccumL f s (x:xs) = (s'',y:ys)
where (s', y ) = f s x
(s'',ys) = mapAccumL f s' xs
insert
insert e ls = insertBy (compare) e ls
insertBy
insertBy _ x [] = [x]
insertBy cmp x ys@(y:ys') = case cmp x y of
GT -> y : insertBy cmp x ys'
_ -> x : ys
maximum
maximum [] = undefined
maximum xs = foldl1 max xs
minimum
minimum [] = undefined
minimum xs = foldl1 min xs
genericLength
genericLength [] = 0
genericLength (_:l) = 1 + genericLength l
group
group = groupBy (==)
groupBy
groupBy _ [] = []
groupBy eq (x:xs) = (x:ys) : groupBy eq zs
where (ys, zs) = span (eq x) xs
inits
inits [] = [[]]
inits (x:xs) = [[]] ++ map (x:) (inits xs)
tails
tails [] = [[]]
tails xxs@(_:xs) = xxs : tails xs
sort
sort = sortBy compare
sortBy
-- The actual definition used by GHC is an optimised mergesort.
sortBy cmp = foldr (insertBy cmp) []
sortWith
sortWith f = sortBy (\x y -> compare (f x) (f y))
the
the (x:xs)
| all (x ==) xs = x
| otherwise = error "GHC.Exts.the: non-identical elements"
the [] = error "GHC.Exts.the: empty list"
unfoldr
unfoldr f b = case f b of
Just (a, b') -> a : unfoldr f b'
Nothing -> []
foldl'
foldl' f a [] = a
foldl' f a (x:xs) = let a' = f a x in a' `seq` foldl' f a' xs
foldl1
foldl1 f (x:xs) = foldl f x xs
foldl1 _ [] = undefined
sum
sum = foldl (+) 0
product
product = foldl (*) 1
unlines
unlines = concatMap (++ "\n")
unwords
unwords [] = ""
unwords ws = foldr1 (\w s -> w ++ ' ':s) ws
words
words s = case dropWhile isSpace s of
"" -> []
s' -> w : words s'' where (w, s'') = break isSpace s'
Maybe
data Maybe a = Nothing | Just a
maybe
maybe n _ Nothing = n
maybe _ f (Just x) = f x
isJust
isJust Nothing = False
isJust _ = True
isNothing
isNothing Nothing = True
isNothing _ = False
fromJust
fromJust Nothing = undefined
fromJust (Just x) = x
fromMaybe
fromMaybe d Nothing = d
fromMaybe _ (Just v) = v
maybeToList
maybeToList Nothing = []
maybeToList (Just x) = [x]
listToMaybe
listToMaybe [] = Nothing
listToMaybe (a:_) = Just a
catMaybes
catMaybes ls = [x | Just x <- ls]
data Either a b = Left a | Right b
either
either f _ (Left x) = f x
either _ g (Right y) = g y
lefts
lefts x = [a | Left a <- x]
rights
rights x = [a | Right a <- x]
isLeft
isLeft (Left _) = True
isLeft (Right _) = False
isRight
isRight (Left _) = False
isRight (Right _) = True
fst
fst (x,_) = x
snd
snd (_,y) = y
curry
curry f x y = f (x, y)
uncurry
uncurry f p = f (fst p) (snd p)
fix
fix f = let x = f x in x
on
(*) `on` f = \x y -> f x * f y
Complex
data (RealFloat a) => Complex a = !a :+ !a
realPart
realPart (x :+ _) = x
imagPart
imagPart (_ :+ y) = y
conjugate
conjugate (x:+y) = x :+ (-y)
mkPolar
mkPolar r theta = r * cos theta :+ r * sin theta
cis
cis theta = cos theta :+ sin theta
polar
polar z = (magnitude z, phase z)
phase
phase (0 :+ 0) = 0
phase (x :+ y) = atan2 y x
toDyn
toDyn v = Dynamic (typeOf v) (unsafeCoerce v)
fromDyn
fromDyn (Dynamic t v) def
| typeOf def == t = unsafeCoerce v
| otherwise = def
fromDynamic
fromDynamic (Dynamic t v) = case unsafeCoerce v of
r | t == typeOf r -> Just r
| otherwise -> Nothing
second f = arr swap >>> first f >>> arr swap
where swap ~(x,y) = (y,x)
(***)
f *** g = first f >>> second g
(&&&)
f &&& g = arr (\b -> (b,b)) >>> f *** g
returnA
returnA = arr id
(^>>)
f ^>> a = arr f >>> a
(>>^)
a >>^ f = a >>> arr f
(<<<)
f <<< g = g >>> f
(<<^)
a <<^ f = a <<< arr f
(^<<)
f ^<< a = arr f <<< a
modifyIORef
modifyIORef ref f = writeIORef ref . f =<< readIORef ref
(<$>)
f <$> a = fmap f a
(<$)
(<$) = (<$>) . const
(*>)
(*>) = liftA2 (const id)
(<*)
(<*) = liftA2 const
(<**>)
(<**>) = liftA2 (flip ($))
liftA
liftA f a = pure f <*> a
liftA2
liftA2 f a b = f <$> a <*> b
optional
optional v = Just <$> v <|> pure Nothing
some
some v = some_v
where many_v = some_v <|> pure []
some_v = (:) <$> v <*> many_v
readMVar
readMVar m = block $ do
a <- takeMVar m
putMVar m a
return a
swapMVar
swapMVar mvar new = block $ do
old <- takeMVar mvar
putMVar mvar new
return old
withMVar m io = block $ do
a <- takeMVar m
b <- Exception.catch (unblock (io a)) (\e -> do putMVar m a; throw e)
putMVar m a
return b
modifyMVar_
modifyMVar_ m io = block $ do
a <- takeMVar m
a' <- Exception.catch (unblock (io a)) (\e -> do putMVar m a; throw e)
putMVar m a'
modifyMVar
modifyMVar m io = block $ do
a <- takeMVar m
(a',b) <- Exception.catch (unblock (io a)) (\e -> do putMVar m a; throw e)
putMVar m a'
return b
handle
handle = flip catch
handleJust
handleJust p = flip (catchJust p)
mapException
mapException f v = unsafePerformIO (catch (evaluate v) (\x -> throw (f x)))
try
try a = catch (a >>= \ v -> return (Right v)) (\e -> return (Left e))
bracket
bracket before after thing = block $ do
a <- before
r <- catch (unblock (thing a)) (\e -> after a >> throw e)
after a
return r
finally
a `finally` sequel = block $ do
r <- catch (unblock a) (\e -> sequel >> throw e)
sequel
return r
bracket_
bracket_ before after thing = bracket before (const after) (const thing)
putChar
putChar c = hPutChar stdout c
putStr
putStr s = hPutStr stdout s
putStrLn
putStrLn s = do putStr s; putChar '\n'
print
print x = putStrLn (show x)
getChar
getChar = hGetChar stdin
getLine
getLine = hGetLine stdin
getContents
getContents = hGetContents stdin
interact
interact f = do s <- getContents; putStr (f s)
readFile
readFile name = openFile name ReadMode >>= hGetContents
writeFile
writeFile f txt = withFile f WriteMode (\ hdl -> hPutStr hdl txt)
appendFile
appendFile f txt = withFile f AppendMode (\ hdl -> hPutStr hdl txt)
readLn
readLn = do l <- getLine; r <- readIO l; return r
hPutStrLn
hPutStrLn hndl str = do hPutStr hndl str; hPutChar hndl '\n'
withFile
withFile name mode = bracket (openFile name mode) hClose
exitFailure
exitFailure = exitWith (ExitFailure 1)
failIO
failIO s = ioError (userError s)
FilePath
type FilePath = String
IORef
newtype IORef a = IORef (STRef RealWorld a)
newIORef
newIORef v = stToIO (newSTRef v) >>= \ var -> return (IORef var)
readIORef
readIORef (IORef var) = stToIO (readSTRef var)
writeIORef
writeIORef (IORef var) v = stToIO (writeSTRef var v)
read
read s = either error id (readEither s)
reads
reads = readsPrec minPrec
readMaybe
readMaybe s = case readEither s of
Left _ -> Nothing
Right a -> Just a
readEither
-- The old-style Read definition. The real one uses readPrec instead.
readEither s =
let s' = dropWhile isSpace s
in case [x | (x, rest) <- reads s', all isSpace rest] of
[x] -> Right x
[] -> Left "Prelude.read: no parse"
_ -> Left "Prelude.read: ambiguous parse"
IOArray
newtype IOArray i e = IOArray (STArray RealWorld i e)
ExitCode
data ExitCode = ExitSuccess | ExitFailure Int
throw
throw exception = raise# exception
IOMode
data IOMode = ReadMode | WriteMode | AppendMode | ReadWriteMode
killThread
killThread tid = throwTo tid (AsyncException ThreadKilled)
STArray
data STArray s i e = STArray !i !i (MutableArray# s e)
(!)
arr@(Array l u _) ! i = unsafeAt arr (index (l,u) i)
bounds
bounds (Array l u _) = (l,u)
indices
indices (Array l u _) = range (l,u)
elems
elems arr@(Array l u _) = [unsafeAt arr i | i <- [0 .. rangeSize (l,u) - 1]]
assocs
assocs arr@(Array l u _) = [(i, unsafeAt arr (unsafeIndex (l,u) i)) | i <- range (l,u)]
(//)
arr@(Array l u _) // ies = unsafeReplace arr [(index (l,u) i, e) | (i, e) <- ies]
undefined
undefined = error "Prelude.undefined"
error
error s = throw (ErrorCall s)
catch
catch m k = catchException m handler where handler (IOException err) = k err
Float
data Float = F# Float#
Double
data Double = D# Double#
ForeignPtr
data ForeignPtr a = ForeignPtr Addr# ForeignPtrContents
ForeignPtrContents
data ForeignPtrContents = PlainForeignPtr !(IORef [IO ()])
| MallocPtr (MutableByteArray# RealWorld) !(IORef [IO ()])
| PlainPtr (MutableByteArray# RealWorld)
Int16
data Int16 = I16# Int#
Int32
data Int32 = I32# Int32#
Int64
data Int64 = I64# Int64#
Integer
data Integer = S# Int#
| J# Int# ByteArray#
(-)
x - y = x + negate y
negate
negate x = 0 - x
subtract
subtract x y = y - x
Ptr
data Ptr a = Ptr Addr#
nullPtr
nullPtr = Ptr nullAddr#