#ifdef __GLASGOW_HASKELL__ #endif module Data.Either ( Either(..), either, lefts, rights, partitionEithers, ) where #include "Typeable.h" #ifdef __GLASGOW_HASKELL__ import GHC.Base import GHC.Show import GHC.Read #endif import Data.Typeable import GHC.Generics (Generic) #ifdef __GLASGOW_HASKELL__ data Either a b = Left a | Right b deriving (Eq, Ord, Read, Show, Generic) either :: (a -> c) -> (b -> c) -> Either a b -> c either f _ (Left x) = f x either _ g (Right y) = g y #endif /* __GLASGOW_HASKELL__ */ INSTANCE_TYPEABLE2(Either,eitherTc,"Either") lefts :: [Either a b] -> [a] lefts x = [a | Left a <- x] rights :: [Either a b] -> [b] rights x = [a | Right a <- x] partitionEithers :: [Either a b] -> ([a],[b]) partitionEithers = foldr (either left right) ([],[]) where left a ~(l, r) = (a:l, r) right a ~(l, r) = (l, a:r)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4