-
Notifications
You must be signed in to change notification settings - Fork 271
/
System-Exit-Lens.html
76 lines (76 loc) · 10.7 KB
/
System-Exit-Lens.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?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/System/Exit/Lens.hs</title>
<link type='text/css' rel='stylesheet' href='hscolour.css' />
</head>
<body>
<pre><a name="line-1"></a><span class='hs-comment'>{-# LANGUAGE MultiParamTypeClasses #-}</span>
<a name="line-2"></a><span class='hs-comment'>{-# LANGUAGE FlexibleInstances #-}</span>
<a name="line-3"></a><span class='hs-comment'>-----------------------------------------------------------------------------</span>
<a name="line-4"></a><span class='hs-comment'>-- |</span>
<a name="line-5"></a><span class='hs-comment'>-- Module : System.Exit.Lens</span>
<a name="line-6"></a><span class='hs-comment'>-- Copyright : (C) 2013 Edward Kmett</span>
<a name="line-7"></a><span class='hs-comment'>-- License : BSD-style (see the file LICENSE)</span>
<a name="line-8"></a><span class='hs-comment'>-- Maintainer : Edward Kmett <ekmett@gmail.com></span>
<a name="line-9"></a><span class='hs-comment'>-- Stability : provisional</span>
<a name="line-10"></a><span class='hs-comment'>-- Portability : Control.Exception</span>
<a name="line-11"></a><span class='hs-comment'>--</span>
<a name="line-12"></a><span class='hs-comment'>-- These prisms can be used with the combinators in "Control.Exception.Lens".</span>
<a name="line-13"></a><span class='hs-comment'>----------------------------------------------------------------------------</span>
<a name="line-14"></a><span class='hs-keyword'>module</span> <span class='hs-conid'>System</span><span class='hs-varop'>.</span><span class='hs-conid'>Exit</span><span class='hs-varop'>.</span><span class='hs-conid'>Lens</span>
<a name="line-15"></a> <span class='hs-layout'>(</span> <span class='hs-conid'>AsExitCode</span><span class='hs-layout'>(</span><span class='hs-keyglyph'>..</span><span class='hs-layout'>)</span>
<a name="line-16"></a> <span class='hs-layout'>,</span> <span class='hs-sel'>_ExitFailure</span>
<a name="line-17"></a> <span class='hs-layout'>,</span> <span class='hs-sel'>_ExitSuccess</span>
<a name="line-18"></a> <span class='hs-layout'>)</span> <span class='hs-keyword'>where</span>
<a name="line-19"></a>
<a name="line-20"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Control</span><span class='hs-varop'>.</span><span class='hs-conid'>Applicative</span>
<a name="line-21"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Control</span><span class='hs-varop'>.</span><span class='hs-conid'>Exception</span>
<a name="line-22"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Control</span><span class='hs-varop'>.</span><span class='hs-conid'>Exception</span><span class='hs-varop'>.</span><span class='hs-conid'>Lens</span>
<a name="line-23"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Control</span><span class='hs-varop'>.</span><span class='hs-conid'>Lens</span>
<a name="line-24"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>System</span><span class='hs-varop'>.</span><span class='hs-conid'>Exit</span>
<a name="line-25"></a>
<a name="line-26"></a><a name="AsExitCode"></a><span class='hs-comment'>-- | Exit codes that a program can return with:</span>
<a name="line-27"></a><a name="AsExitCode"></a><span class='hs-keyword'>class</span> <span class='hs-conid'>AsExitCode</span> <span class='hs-varid'>p</span> <span class='hs-varid'>f</span> <span class='hs-varid'>t</span> <span class='hs-keyword'>where</span>
<a name="line-28"></a> <span class='hs-comment'>-- |</span>
<a name="line-29"></a> <span class='hs-comment'>-- @</span>
<a name="line-30"></a> <span class='hs-comment'>-- '_ExitCode' :: 'Equality'' 'ExitCode' 'ExitCode'</span>
<a name="line-31"></a> <span class='hs-comment'>-- '_ExitCode' :: 'Prism'' 'SomeException' 'ExitCode'</span>
<a name="line-32"></a> <span class='hs-comment'>-- @</span>
<a name="line-33"></a> <span class='hs-sel'>_ExitCode</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Overloaded'</span> <span class='hs-varid'>p</span> <span class='hs-varid'>f</span> <span class='hs-varid'>t</span> <span class='hs-conid'>ExitCode</span>
<a name="line-34"></a>
<a name="line-35"></a><span class='hs-keyword'>instance</span> <span class='hs-conid'>AsExitCode</span> <span class='hs-varid'>p</span> <span class='hs-varid'>f</span> <span class='hs-conid'>ExitCode</span> <span class='hs-keyword'>where</span>
<a name="line-36"></a> <span class='hs-sel'>_ExitCode</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>id</span>
<a name="line-37"></a> <span class='hs-comment'>{-# INLINE _ExitCode #-}</span>
<a name="line-38"></a>
<a name="line-39"></a><span class='hs-keyword'>instance</span> <span class='hs-layout'>(</span><span class='hs-conid'>Choice</span> <span class='hs-varid'>p</span><span class='hs-layout'>,</span> <span class='hs-conid'>Applicative</span> <span class='hs-varid'>f</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=></span> <span class='hs-conid'>AsExitCode</span> <span class='hs-varid'>p</span> <span class='hs-varid'>f</span> <span class='hs-conid'>SomeException</span> <span class='hs-keyword'>where</span>
<a name="line-40"></a> <span class='hs-sel'>_ExitCode</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>exception</span>
<a name="line-41"></a> <span class='hs-comment'>{-# INLINE _ExitCode #-}</span>
<a name="line-42"></a>
<a name="line-43"></a><span class='hs-comment'>-- | indicates successful termination;</span>
<a name="line-44"></a><span class='hs-comment'>--</span>
<a name="line-45"></a><span class='hs-comment'>-- @</span>
<a name="line-46"></a><span class='hs-comment'>-- '_ExitSuccess' :: 'Prism'' 'ExitCode' ()</span>
<a name="line-47"></a><span class='hs-comment'>-- '_ExitSuccess' :: 'Prism'' 'SomeException' ()</span>
<a name="line-48"></a><span class='hs-comment'>-- @</span>
<a name="line-49"></a><span class='hs-sel'>_ExitSuccess</span> <span class='hs-keyglyph'>::</span> <span class='hs-layout'>(</span><span class='hs-conid'>AsExitCode</span> <span class='hs-varid'>p</span> <span class='hs-varid'>f</span> <span class='hs-varid'>t</span><span class='hs-layout'>,</span> <span class='hs-conid'>Choice</span> <span class='hs-varid'>p</span><span class='hs-layout'>,</span> <span class='hs-conid'>Applicative</span> <span class='hs-varid'>f</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=></span> <span class='hs-conid'>Overloaded'</span> <span class='hs-varid'>p</span> <span class='hs-varid'>f</span> <span class='hs-varid'>t</span> <span class='hs-conid'>()</span>
<a name="line-50"></a><span class='hs-sel'>_ExitSuccess</span> <span class='hs-keyglyph'>=</span> <span class='hs-sel'>_ExitCode</span> <span class='hs-varop'>.</span> <span class='hs-varid'>dimap</span> <span class='hs-varid'>seta</span> <span class='hs-layout'>(</span><span class='hs-varid'>either</span> <span class='hs-varid'>id</span> <span class='hs-varid'>id</span><span class='hs-layout'>)</span> <span class='hs-varop'>.</span> <span class='hs-varid'>right'</span> <span class='hs-varop'>.</span> <span class='hs-varid'>rmap</span> <span class='hs-layout'>(</span><span class='hs-conid'>ExitSuccess</span> <span class='hs-varop'><$</span><span class='hs-layout'>)</span> <span class='hs-keyword'>where</span>
<a name="line-51"></a> <span class='hs-varid'>seta</span> <span class='hs-conid'>ExitSuccess</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>Right</span> <span class='hs-conid'>()</span>
<a name="line-52"></a> <span class='hs-varid'>seta</span> <span class='hs-varid'>t</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>Left</span> <span class='hs-layout'>(</span><span class='hs-varid'>pure</span> <span class='hs-varid'>t</span><span class='hs-layout'>)</span>
<a name="line-53"></a><span class='hs-comment'>{-# INLINE _ExitSuccess #-}</span>
<a name="line-54"></a>
<a name="line-55"></a><span class='hs-comment'>-- | indicates program failure with an exit code. The exact interpretation of the code is operating-system dependent. In particular, some values may be prohibited (e.g. 0 on a POSIX-compliant system).</span>
<a name="line-56"></a><span class='hs-comment'>--</span>
<a name="line-57"></a><span class='hs-comment'>-- @</span>
<a name="line-58"></a><span class='hs-comment'>-- '_ExitFailure' :: 'Prism'' 'ExitCode' 'Int'</span>
<a name="line-59"></a><span class='hs-comment'>-- '_ExitFailure' :: 'Prism'' 'SomeException' 'Int'</span>
<a name="line-60"></a><span class='hs-comment'>-- @</span>
<a name="line-61"></a><span class='hs-sel'>_ExitFailure</span> <span class='hs-keyglyph'>::</span> <span class='hs-layout'>(</span><span class='hs-conid'>AsExitCode</span> <span class='hs-varid'>p</span> <span class='hs-varid'>f</span> <span class='hs-varid'>t</span><span class='hs-layout'>,</span> <span class='hs-conid'>Choice</span> <span class='hs-varid'>p</span><span class='hs-layout'>,</span> <span class='hs-conid'>Applicative</span> <span class='hs-varid'>f</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=></span> <span class='hs-conid'>Overloaded'</span> <span class='hs-varid'>p</span> <span class='hs-varid'>f</span> <span class='hs-varid'>t</span> <span class='hs-conid'>Int</span>
<a name="line-62"></a><span class='hs-sel'>_ExitFailure</span> <span class='hs-keyglyph'>=</span> <span class='hs-sel'>_ExitCode</span> <span class='hs-varop'>.</span> <span class='hs-varid'>dimap</span> <span class='hs-varid'>seta</span> <span class='hs-layout'>(</span><span class='hs-varid'>either</span> <span class='hs-varid'>id</span> <span class='hs-varid'>id</span><span class='hs-layout'>)</span> <span class='hs-varop'>.</span> <span class='hs-varid'>right'</span> <span class='hs-varop'>.</span> <span class='hs-varid'>rmap</span> <span class='hs-layout'>(</span><span class='hs-varid'>fmap</span> <span class='hs-conid'>ExitFailure</span><span class='hs-layout'>)</span> <span class='hs-keyword'>where</span>
<a name="line-63"></a> <span class='hs-varid'>seta</span> <span class='hs-layout'>(</span><span class='hs-conid'>ExitFailure</span> <span class='hs-varid'>i</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>Right</span> <span class='hs-varid'>i</span>
<a name="line-64"></a> <span class='hs-varid'>seta</span> <span class='hs-varid'>t</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>Left</span> <span class='hs-layout'>(</span><span class='hs-varid'>pure</span> <span class='hs-varid'>t</span><span class='hs-layout'>)</span>
<a name="line-65"></a><span class='hs-comment'>{-# INLINE _ExitFailure #-}</span>
</pre></body>
</html>