<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <!-- Generated by HsColour, http://www.cs.york.ac.uk/fp/darcs/hscolour/ --> <title>src/Data/Maybe/Utils.hs</title> <link type='text/css' rel='stylesheet' href='hscolour.css' /> </head> <body> <pre><a name="line-1"></a><span class='hs-comment'>{- arch-tag: Maybe utilities <a name="line-2"></a>Copyright (C) 2004 John Goerzen <jgoerzen@complete.org> <a name="line-3"></a> <a name="line-4"></a>This program is free software; you can redistribute it and/or modify <a name="line-5"></a>it under the terms of the GNU General Public License as published by <a name="line-6"></a>the Free Software Foundation; either version 2 of the License, or <a name="line-7"></a>(at your option) any later version. <a name="line-8"></a> <a name="line-9"></a>This program is distributed in the hope that it will be useful, <a name="line-10"></a>but WITHOUT ANY WARRANTY; without even the implied warranty of <a name="line-11"></a>MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the <a name="line-12"></a>GNU General Public License for more details. <a name="line-13"></a> <a name="line-14"></a>You should have received a copy of the GNU General Public License <a name="line-15"></a>along with this program; if not, write to the Free Software <a name="line-16"></a>Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA <a name="line-17"></a>-}</span> <a name="line-18"></a> <a name="line-19"></a><span class='hs-comment'>{- | <a name="line-20"></a> Module : Data.Maybe.Utils <a name="line-21"></a> Copyright : Copyright (C) 2005 John Goerzen <a name="line-22"></a> License : GNU GPL, version 2 or above <a name="line-23"></a> <a name="line-24"></a> Maintainer : John Goerzen <jgoerzen@complete.org> <a name="line-25"></a> Stability : provisional <a name="line-26"></a> Portability: portable <a name="line-27"></a> <a name="line-28"></a>Utilities for working with the Either data type <a name="line-29"></a> <a name="line-30"></a>Copyright (c) 2004 John Goerzen, jgoerzen\@complete.org <a name="line-31"></a>-}</span> <a name="line-32"></a><span class='hs-keyword'>module</span> <span class='hs-conid'>Data</span><span class='hs-varop'>.</span><span class='hs-conid'>Maybe</span><span class='hs-varop'>.</span><span class='hs-conid'>Utils</span> <a name="line-33"></a> <span class='hs-layout'>(</span> <a name="line-34"></a> <span class='hs-varid'>forceMaybe</span><span class='hs-layout'>,</span> <span class='hs-varid'>forceMaybeMsg</span> <a name="line-35"></a><span class='hs-layout'>)</span> <span class='hs-keyword'>where</span> <a name="line-36"></a> <a name="line-37"></a><a name="forceMaybe"></a><span class='hs-comment'>{- | Pulls a Just value out of a Maybe value. If the Maybe value is <a name="line-38"></a>Nothing, raises an exception with error. -}</span> <a name="line-39"></a><span class='hs-definition'>forceMaybe</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Maybe</span> <span class='hs-varid'>a</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>a</span> <a name="line-40"></a><span class='hs-definition'>forceMaybe</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>forceMaybeMsg</span> <span class='hs-str'>"forceMaybe: Got Nothing"</span> <a name="line-41"></a> <a name="line-42"></a><a name="forceMaybeMsg"></a><span class='hs-comment'>{- | Like 'forceMaybe', but lets you customize the error message raised if <a name="line-43"></a>Nothing is supplied. -}</span> <a name="line-44"></a><span class='hs-definition'>forceMaybeMsg</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>String</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Maybe</span> <span class='hs-varid'>a</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>a</span> <a name="line-45"></a><span class='hs-definition'>forceMaybeMsg</span> <span class='hs-varid'>msg</span> <span class='hs-conid'>Nothing</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>error</span> <span class='hs-varid'>msg</span> <a name="line-46"></a><span class='hs-definition'>forceMaybeMsg</span> <span class='hs-keyword'>_</span> <span class='hs-layout'>(</span><span class='hs-conid'>Just</span> <span class='hs-varid'>x</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>x</span> </pre></body> </html>