-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfpkit.hs
More file actions
33 lines (21 loc) · 731 Bytes
/
fpkit.hs
File metadata and controls
33 lines (21 loc) · 731 Bytes
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
module FPKit where
import Maybe (fromJust, isJust)
{- FP utilities -}
cross f g (x,y) = (f x, g y)
onRight f = cross id f
onLeft f = cross f id
($>) x f = f x
image x = fromJust . lookup x
maps x = Maybe.isJust . lookup x
onBoth f (a, b) = (f a, f b)
isRight (Right _) = True
isRight (Left _ ) = False
isLeft (Left _) = True
isLeft (Right _ ) = False
errorMToBool = either (const False) (const True)
-- withErrMsg msg expr = unsafePerformIO $ catch (evaluate expr)
-- (\e ->
-- case e of
-- Control.Exception.ErrorCall str ->
-- error $ msg ++ str
-- _ -> error msg)