8 | data IMaybe : Bool -> Type -> Type where
9 | Just : a -> IMaybe True a
10 | Nothing : IMaybe False a
13 | fromJust : IMaybe True a -> a
14 | fromJust (Just a) = a
17 | Functor (IMaybe b) where
18 | map f (Just a) = Just (f a)
19 | map f Nothing = Nothing
22 | Applicative (IMaybe True) where
24 | Just f <*> Just x = Just (f x)
27 | Zippable (IMaybe b) where
28 | zipWith f Nothing Nothing = Nothing
29 | zipWith f (Just x) (Just y) = Just $
f x y
31 | zipWith3 f Nothing Nothing Nothing = Nothing
32 | zipWith3 f (Just x) (Just y) (Just z) = Just $
f x y z
34 | unzipWith f Nothing = (Nothing, Nothing)
35 | unzipWith f (Just x) = let (a, b) = f x in (Just a, Just b)
37 | unzipWith3 f Nothing = (Nothing, Nothing, Nothing)
38 | unzipWith3 f (Just x) = let (a, b, c) = f x in (Just a, Just b, Just c)