haskell-lectures/VL1/content/VL1_ADT4.tex

7 lines
286 B
TeX
Raw Normal View History

And pattern match on it as well:
\begin{haskellcode}
addIntToList :: MaybeInt -> [Int]
addIntToList (NoError x) = [x]
addIntToList (Error str) = []
\end{haskellcode}
So if we got an error, we just return an empty list, otherwise we return a list with the \code{Int} as its only element.