44 lines
4.2 KiB
HTML
44 lines
4.2 KiB
HTML
|
<?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://code.haskell.org/~malcolm/hscolour/ -->
|
||
|
<title>src/HPath/IO/Utils.hs</title>
|
||
|
<link type='text/css' rel='stylesheet' href='hscolour.css' />
|
||
|
</head>
|
||
|
<body>
|
||
|
<pre><a name="line-1"></a><span class='hs-comment'>-- |</span>
|
||
|
<a name="line-2"></a><span class='hs-comment'>-- Module : HPath.IO.Utils</span>
|
||
|
<a name="line-3"></a><span class='hs-comment'>-- Copyright : © 2016 Julian Ospald</span>
|
||
|
<a name="line-4"></a><span class='hs-comment'>-- License : GPL-2</span>
|
||
|
<a name="line-5"></a><span class='hs-comment'>--</span>
|
||
|
<a name="line-6"></a><span class='hs-comment'>-- Maintainer : Julian Ospald <hasufell@posteo.de></span>
|
||
|
<a name="line-7"></a><span class='hs-comment'>-- Stability : experimental</span>
|
||
|
<a name="line-8"></a><span class='hs-comment'>-- Portability : portable</span>
|
||
|
<a name="line-9"></a><span class='hs-comment'>--</span>
|
||
|
<a name="line-10"></a><span class='hs-comment'>-- Random and general IO/monad utilities.</span>
|
||
|
<a name="line-11"></a>
|
||
|
<a name="line-12"></a>
|
||
|
<a name="line-13"></a><span class='hs-keyword'>module</span> <span class='hs-conid'>HPath</span><span class='hs-varop'>.</span><span class='hs-conid'>IO</span><span class='hs-varop'>.</span><span class='hs-conid'>Utils</span> <span class='hs-keyword'>where</span>
|
||
|
<a name="line-14"></a>
|
||
|
<a name="line-15"></a>
|
||
|
<a name="line-16"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Control</span><span class='hs-varop'>.</span><span class='hs-conid'>Monad</span>
|
||
|
<a name="line-17"></a> <span class='hs-layout'>(</span>
|
||
|
<a name="line-18"></a> <span class='hs-varid'>when</span>
|
||
|
<a name="line-19"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>unless</span>
|
||
|
<a name="line-20"></a> <span class='hs-layout'>)</span>
|
||
|
<a name="line-21"></a>
|
||
|
<a name="line-22"></a>
|
||
|
<a name="line-23"></a><a name="whenM"></a><span class='hs-comment'>-- |If the value of the first argument is True, then execute the action</span>
|
||
|
<a name="line-24"></a><span class='hs-comment'>-- provided in the second argument, otherwise do nothing.</span>
|
||
|
<a name="line-25"></a><span class='hs-definition'>whenM</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Monad</span> <span class='hs-varid'>m</span> <span class='hs-keyglyph'>=></span> <span class='hs-varid'>m</span> <span class='hs-conid'>Bool</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>m</span> <span class='hs-conid'>()</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>m</span> <span class='hs-conid'>()</span>
|
||
|
<a name="line-26"></a><span class='hs-definition'>whenM</span> <span class='hs-varid'>mb</span> <span class='hs-varid'>a</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>mb</span> <span class='hs-varop'>>>=</span> <span class='hs-layout'>(</span><span class='hs-varop'>`when`</span> <span class='hs-varid'>a</span><span class='hs-layout'>)</span>
|
||
|
<a name="line-27"></a>
|
||
|
<a name="line-28"></a>
|
||
|
<a name="line-29"></a><a name="unlessM"></a><span class='hs-comment'>-- |If the value of the first argument is False, then execute the action</span>
|
||
|
<a name="line-30"></a><span class='hs-comment'>-- provided in the second argument, otherwise do nothing.</span>
|
||
|
<a name="line-31"></a><span class='hs-definition'>unlessM</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Monad</span> <span class='hs-varid'>m</span> <span class='hs-keyglyph'>=></span> <span class='hs-varid'>m</span> <span class='hs-conid'>Bool</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>m</span> <span class='hs-conid'>()</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>m</span> <span class='hs-conid'>()</span>
|
||
|
<a name="line-32"></a><span class='hs-definition'>unlessM</span> <span class='hs-varid'>mb</span> <span class='hs-varid'>a</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>mb</span> <span class='hs-varop'>>>=</span> <span class='hs-layout'>(</span><span class='hs-varop'>`unless`</span> <span class='hs-varid'>a</span><span class='hs-layout'>)</span>
|
||
|
</pre></body>
|
||
|
</html>
|