on master help sign in
Alternative instances for Maybe and List
376b4b5startling
lib/Prelude.idr+13
@@ -109,6 +109,19 @@ instance Applicative List where
109
109
110 fs <$> vs = concatMap (\f => map f vs) fs
110 fs <$> vs = concatMap (\f => map f vs) fs
111
111
112+---- Alternative instances
113+
114+instance Alternative Maybe where
115+ empty = Nothing
116+
117+ (Just x) <|> _ = Just x
118+ Nothing <|> v = v
119+
120+instance Alternative List where
121+ empty = []
122+
123+ (<|>) = (++)
124+
112---- Monad instances
125---- Monad instances
113
126
114instance Monad IO where
127instance Monad IO where