git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Change the order of some prelude instances
5fd3f6dPhil Freeman
prelude/prelude.purs+14−14
@@ -441,19 +441,19 @@ module Maybe where
441 fromMaybe :: forall a. a -> Maybe a -> a
441 fromMaybe :: forall a. a -> Maybe a -> a
442 fromMaybe a = maybe a (Prelude.id :: forall a. a -> a)
442 fromMaybe a = maybe a (Prelude.id :: forall a. a -> a)
443
443
444− instance Prelude.Functor Maybe where
444+ instance Prelude.Monad Maybe where
445− (<$>) fn (Just x) = Just (fn x)
445+ return = Just
446− (<$>) _ _ = Nothing
446+ (>>=) m f = maybe Nothing f m
447−
447+
448 instance Prelude.Applicative Maybe where
448 instance Prelude.Applicative Maybe where
449 pure = Just
449 pure = Just
450 (<*>) (Just fn) x = fn <$> x
450 (<*>) (Just fn) x = fn <$> x
451 (<*>) Nothing _ = Nothing
451 (<*>) Nothing _ = Nothing
452
452
453− instance Prelude.Monad Maybe where
453+ instance Prelude.Functor Maybe where
454− return = Just
454+ (<$>) fn (Just x) = Just (fn x)
455− (>>=) m f = maybe Nothing f m
455+ (<$>) _ _ = Nothing
456−
456+
457 instance (Show a) => Prelude.Show (Maybe a) where
457 instance (Show a) => Prelude.Show (Maybe a) where
458 show (Just x) = "Just " ++ (show x)
458 show (Just x) = "Just " ++ (show x)
459 show Nothing = "Nothing"
459 show Nothing = "Nothing"
@@ -468,18 +468,18 @@ module Either where
468 either f _ (Left a) = f a
468 either f _ (Left a) = f a
469 either _ g (Right b) = g b
469 either _ g (Right b) = g b
470
470
471− instance Prelude.Functor (Either a) where
471+ instance Prelude.Monad (Either e) where
472− (<$>) _ (Left x) = Left x
472+ return = Right
473− (<$>) f (Right y) = Right (f y)
473+ (>>=) = either (\e _ -> Left e) (\a f -> f a)
474
474
475 instance Prelude.Applicative (Either e) where
475 instance Prelude.Applicative (Either e) where
476 pure = Right
476 pure = Right
477 (<*>) (Left e) _ = Left e
477 (<*>) (Left e) _ = Left e
478 (<*>) (Right f) r = f <$> r
478 (<*>) (Right f) r = f <$> r
479
479
480− instance Prelude.Monad (Either e) where
480+ instance Prelude.Functor (Either a) where
481− return = Right
481+ (<$>) _ (Left x) = Left x
482− (>>=) = either (\e _ -> Left e) (\a f -> f a)
482+ (<$>) f (Right y) = Right (f y)
483
483
484 instance (Show a, Show b) => Prelude.Show (Either a b) where
484 instance (Show a, Show b) => Prelude.Show (Either a b) where
485 show (Left x) = "Left " ++ (show x)
485 show (Left x) = "Left " ++ (show x)