on master help sign in
Alternative instances for Maybe and List
commit376b4b568033f96741d4ad54008fbb64bbb89554 authorstartling <tdixon51793@gmail.com> dateThu 13 Dec 2012, 20:38 (14 years ago) parent2d17b67
1 file changed+13
lib/Prelude.idr+13
lib/Prelude.idr+13
@@ -109,6 +109,19 @@ instance Applicative List where
109109
110110 fs <$> vs = concatMap (\f => map f vs) fs
111111
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+
112125---- Monad instances
113126
114127instance Monad IO where