mirror of
https://git8.cs.fau.de/theses/bsc-leon-vatthauer.git
synced 2024-05-31 07:28:34 +02:00
140 lines
37 KiB
HTML
140 lines
37 KiB
HTML
|
<!DOCTYPE HTML>
|
|||
|
<html><head><meta charset="utf-8"><title>Data.Maybe.Base</title><link rel="stylesheet" href="Agda.css"></head><body><pre class="Agda"><a id="1" class="Comment">------------------------------------------------------------------------</a>
|
|||
|
<a id="74" class="Comment">-- The Agda standard library</a>
|
|||
|
<a id="103" class="Comment">--</a>
|
|||
|
<a id="106" class="Comment">-- The Maybe type and some operations</a>
|
|||
|
<a id="144" class="Comment">------------------------------------------------------------------------</a>
|
|||
|
|
|||
|
<a id="218" class="Comment">-- The definitions in this file are reexported by Data.Maybe.</a>
|
|||
|
|
|||
|
<a id="281" class="Symbol">{-#</a> <a id="285" class="Keyword">OPTIONS</a> <a id="293" class="Pragma">--cubical-compatible</a> <a id="314" class="Pragma">--safe</a> <a id="321" class="Symbol">#-}</a>
|
|||
|
|
|||
|
<a id="326" class="Keyword">module</a> <a id="333" href="Data.Maybe.Base.html" class="Module">Data.Maybe.Base</a> <a id="349" class="Keyword">where</a>
|
|||
|
|
|||
|
<a id="356" class="Keyword">open</a> <a id="361" class="Keyword">import</a> <a id="368" href="Level.html" class="Module">Level</a>
|
|||
|
<a id="374" class="Keyword">open</a> <a id="379" class="Keyword">import</a> <a id="386" href="Data.Bool.Base.html" class="Module">Data.Bool.Base</a> <a id="401" class="Keyword">using</a> <a id="407" class="Symbol">(</a><a id="408" href="Agda.Builtin.Bool.html#156" class="Datatype">Bool</a><a id="412" class="Symbol">;</a> <a id="414" href="Agda.Builtin.Bool.html#181" class="InductiveConstructor">true</a><a id="418" class="Symbol">;</a> <a id="420" href="Agda.Builtin.Bool.html#175" class="InductiveConstructor">false</a><a id="425" class="Symbol">;</a> <a id="427" href="Data.Bool.Base.html#941" class="Function">not</a><a id="430" class="Symbol">)</a>
|
|||
|
<a id="432" class="Keyword">open</a> <a id="437" class="Keyword">import</a> <a id="444" href="Data.Unit.Base.html" class="Module">Data.Unit.Base</a> <a id="459" class="Keyword">using</a> <a id="465" class="Symbol">(</a><a id="466" href="Agda.Builtin.Unit.html#158" class="Record">⊤</a><a id="467" class="Symbol">)</a>
|
|||
|
<a id="469" class="Keyword">open</a> <a id="474" class="Keyword">import</a> <a id="481" href="Data.These.Base.html" class="Module">Data.These.Base</a> <a id="497" class="Keyword">using</a> <a id="503" class="Symbol">(</a><a id="504" href="Data.These.Base.html#537" class="Datatype">These</a><a id="509" class="Symbol">;</a> <a id="511" href="Data.These.Base.html#595" class="InductiveConstructor">this</a><a id="515" class="Symbol">;</a> <a id="517" href="Data.These.Base.html#623" class="InductiveConstructor">that</a><a id="521" class="Symbol">;</a> <a id="523" href="Data.These.Base.html#651" class="InductiveConstructor">these</a><a id="528" class="Symbol">)</a>
|
|||
|
<a id="530" class="Keyword">open</a> <a id="535" class="Keyword">import</a> <a id="542" href="Data.Product.html" class="Module">Data.Product</a> <a id="555" class="Symbol">as</a> <a id="558" class="Module">Prod</a> <a id="563" class="Keyword">using</a> <a id="569" class="Symbol">(</a><a id="570" href="Data.Product.html#1176" class="Function Operator">_×_</a><a id="573" class="Symbol">;</a> <a id="575" href="Agda.Builtin.Sigma.html#218" class="InductiveConstructor Operator">_,_</a><a id="578" class="Symbol">)</a>
|
|||
|
<a id="580" class="Keyword">open</a> <a id="585" class="Keyword">import</a> <a id="592" href="Function.Base.html" class="Module">Function.Base</a>
|
|||
|
<a id="606" class="Keyword">open</a> <a id="611" class="Keyword">import</a> <a id="618" href="Relation.Nullary.Reflects.html" class="Module">Relation.Nullary.Reflects</a>
|
|||
|
<a id="644" class="Keyword">open</a> <a id="649" class="Keyword">import</a> <a id="656" href="Relation.Nullary.html" class="Module">Relation.Nullary</a>
|
|||
|
|
|||
|
<a id="674" class="Keyword">private</a>
|
|||
|
<a id="684" class="Keyword">variable</a>
|
|||
|
<a id="697" href="Data.Maybe.Base.html#697" class="Generalizable">a</a> <a id="699" href="Data.Maybe.Base.html#699" class="Generalizable">b</a> <a id="701" href="Data.Maybe.Base.html#701" class="Generalizable">c</a> <a id="703" class="Symbol">:</a> <a id="705" href="Agda.Primitive.html#591" class="Postulate">Level</a>
|
|||
|
<a id="715" href="Data.Maybe.Base.html#715" class="Generalizable">A</a> <a id="717" class="Symbol">:</a> <a id="719" href="Agda.Primitive.html#320" class="Primitive">Set</a> <a id="723" href="Data.Maybe.Base.html#697" class="Generalizable">a</a>
|
|||
|
<a id="729" href="Data.Maybe.Base.html#729" class="Generalizable">B</a> <a id="731" class="Symbol">:</a> <a id="733" href="Agda.Primitive.html#320" class="Primitive">Set</a> <a id="737" href="Data.Maybe.Base.html#699" class="Generalizable">b</a>
|
|||
|
<a id="743" href="Data.Maybe.Base.html#743" class="Generalizable">C</a> <a id="745" class="Symbol">:</a> <a id="747" href="Agda.Primitive.html#320" class="Primitive">Set</a> <a id="751" href="Data.Maybe.Base.html#701" class="Generalizable">c</a>
|
|||
|
|
|||
|
<a id="754" class="Comment">------------------------------------------------------------------------</a>
|
|||
|
<a id="827" class="Comment">-- Definition</a>
|
|||
|
|
|||
|
<a id="842" class="Keyword">open</a> <a id="847" class="Keyword">import</a> <a id="854" href="Agda.Builtin.Maybe.html" class="Module">Agda.Builtin.Maybe</a> <a id="873" class="Keyword">public</a>
|
|||
|
<a id="882" class="Keyword">using</a> <a id="888" class="Symbol">(</a><a id="889" href="Agda.Builtin.Maybe.html#118" class="Datatype">Maybe</a><a id="894" class="Symbol">;</a> <a id="896" href="Agda.Builtin.Maybe.html#156" class="InductiveConstructor">just</a><a id="900" class="Symbol">;</a> <a id="902" href="Agda.Builtin.Maybe.html#177" class="InductiveConstructor">nothing</a><a id="909" class="Symbol">)</a>
|
|||
|
|
|||
|
<a id="912" class="Comment">------------------------------------------------------------------------</a>
|
|||
|
<a id="985" class="Comment">-- Some operations</a>
|
|||
|
|
|||
|
<a id="boolToMaybe"></a><a id="1005" href="Data.Maybe.Base.html#1005" class="Function">boolToMaybe</a> <a id="1017" class="Symbol">:</a> <a id="1019" href="Agda.Builtin.Bool.html#156" class="Datatype">Bool</a> <a id="1024" class="Symbol">→</a> <a id="1026" href="Agda.Builtin.Maybe.html#118" class="Datatype">Maybe</a> <a id="1032" href="Agda.Builtin.Unit.html#158" class="Record">⊤</a>
|
|||
|
<a id="1034" href="Data.Maybe.Base.html#1005" class="Function">boolToMaybe</a> <a id="1046" href="Agda.Builtin.Bool.html#181" class="InductiveConstructor">true</a> <a id="1052" class="Symbol">=</a> <a id="1054" href="Agda.Builtin.Maybe.html#156" class="InductiveConstructor">just</a> <a id="1059" class="Symbol">_</a>
|
|||
|
<a id="1061" href="Data.Maybe.Base.html#1005" class="Function">boolToMaybe</a> <a id="1073" href="Agda.Builtin.Bool.html#175" class="InductiveConstructor">false</a> <a id="1079" class="Symbol">=</a> <a id="1081" href="Agda.Builtin.Maybe.html#177" class="InductiveConstructor">nothing</a>
|
|||
|
|
|||
|
<a id="is-just"></a><a id="1090" href="Data.Maybe.Base.html#1090" class="Function">is-just</a> <a id="1098" class="Symbol">:</a> <a id="1100" href="Agda.Builtin.Maybe.html#118" class="Datatype">Maybe</a> <a id="1106" href="Data.Maybe.Base.html#715" class="Generalizable">A</a> <a id="1108" class="Symbol">→</a> <a id="1110" href="Agda.Builtin.Bool.html#156" class="Datatype">Bool</a>
|
|||
|
<a id="1115" href="Data.Maybe.Base.html#1090" class="Function">is-just</a> <a id="1123" class="Symbol">(</a><a id="1124" href="Agda.Builtin.Maybe.html#156" class="InductiveConstructor">just</a> <a id="1129" class="Symbol">_)</a> <a id="1132" class="Symbol">=</a> <a id="1134" href="Agda.Builtin.Bool.html#181" class="InductiveConstructor">true</a>
|
|||
|
<a id="1139" href="Data.Maybe.Base.html#1090" class="Function">is-just</a> <a id="1147" href="Agda.Builtin.Maybe.html#177" class="InductiveConstructor">nothing</a> <a id="1156" class="Symbol">=</a> <a id="1158" href="Agda.Builtin.Bool.html#175" class="InductiveConstructor">false</a>
|
|||
|
|
|||
|
<a id="is-nothing"></a><a id="1165" href="Data.Maybe.Base.html#1165" class="Function">is-nothing</a> <a id="1176" class="Symbol">:</a> <a id="1178" href="Agda.Builtin.Maybe.html#118" class="Datatype">Maybe</a> <a id="1184" href="Data.Maybe.Base.html#715" class="Generalizable">A</a> <a id="1186" class="Symbol">→</a> <a id="1188" href="Agda.Builtin.Bool.html#156" class="Datatype">Bool</a>
|
|||
|
<a id="1193" href="Data.Maybe.Base.html#1165" class="Function">is-nothing</a> <a id="1204" class="Symbol">=</a> <a id="1206" href="Data.Bool.Base.html#941" class="Function">not</a> <a id="1210" href="Function.Base.html#1040" class="Function Operator">∘</a> <a id="1212" href="Data.Maybe.Base.html#1090" class="Function">is-just</a>
|
|||
|
|
|||
|
<a id="decToMaybe"></a><a id="1221" href="Data.Maybe.Base.html#1221" class="Function">decToMaybe</a> <a id="1232" class="Symbol">:</a> <a id="1234" href="Relation.Nullary.html#1520" class="Record">Dec</a> <a id="1238" href="Data.Maybe.Base.html#715" class="Generalizable">A</a> <a id="1240" class="Symbol">→</a> <a id="1242" href="Agda.Builtin.Maybe.html#118" class="Datatype">Maybe</a> <a id="1248" href="Data.Maybe.Base.html#715" class="Generalizable">A</a>
|
|||
|
<a id="1250" href="Data.Maybe.Base.html#1221" class="Function">decToMaybe</a> <a id="1261" class="Symbol">(</a> <a id="1263" href="Agda.Builtin.Bool.html#181" class="InductiveConstructor">true</a> <a id="1268" href="Relation.Nullary.html#1568" class="InductiveConstructor Operator">because</a> <a id="1276" href="Data.Maybe.Base.html#1276" class="Bound">[a]</a><a id="1279" class="Symbol">)</a> <a id="1281" class="Symbol">=</a> <a id="1283" href="Agda.Builtin.Maybe.html#156" class="InductiveConstructor">just</a> <a id="1288" class="Symbol">(</a><a id="1289" href="Relation.Nullary.Reflects.html#1040" class="Function">invert</a> <a id="1296" href="Data.Maybe.Base.html#1276" class="Bound">[a]</a><a id="1299" class="Symbol">)</a>
|
|||
|
<a id="1301" href="Data.Maybe.Base.html#1221" class="Function">decToMaybe</a> <a id="1312" class="Symbol">(</a><a id="1313" href="Agda.Builtin.Bool.html#175" class="InductiveConstructor">false</a> <a id="1319" href="Relation.Nullary.html#1568" class="InductiveConstructor Operator">because</a> <a id="1328" class="Symbol">_</a> <a id="1330" class="Symbol">)</a> <a id="1332" class="Symbol">=</a> <a id="1334" href="Agda.Builtin.Maybe.html#177" class="InductiveConstructor">nothing</a>
|
|||
|
|
|||
|
<a id="1343" class="Comment">-- A dependent eliminator.</a>
|
|||
|
|
|||
|
<a id="maybe"></a><a id="1371" href="Data.Maybe.Base.html#1371" class="Function">maybe</a> <a id="1377" class="Symbol">:</a> <a id="1379" class="Symbol">∀</a> <a id="1381" class="Symbol">{</a><a id="1382" href="Data.Maybe.Base.html#1382" class="Bound">A</a> <a id="1384" class="Symbol">:</a> <a id="1386" href="Agda.Primitive.html#320" class="Primitive">Set</a> <a id="1390" href="Data.Maybe.Base.html#697" class="Generalizable">a</a><a id="1391" class="Symbol">}</a> <a id="1393" class="Symbol">{</a><a id="1394" href="Data.Maybe.Base.html#1394" class="Bound">B</a> <a id="1396" class="Symbol">:</a> <a id="1398" href="Agda.Builtin.Maybe.html#118" class="Datatype">Maybe</a> <a id="1404" href="Data.Maybe.Base.html#1382" class="Bound">A</a> <a id="1406" class="Symbol">→</a> <a id="1408" href="Agda.Primitive.html#320" class="Primitive">Set</a> <a id="1412" href="Data.Maybe.Base.html#699" class="Generalizable">b</a><a id="1413" class="Symbol">}</a> <a id="1415" class="Symbol">→</a>
|
|||
|
<a id="1425" class="Symbol">((</a><a id="1427" href="Data.Maybe.Base.html#1427" class="Bound">x</a> <a id="1429" class="Symbol">:</a> <a id="1431" href="Data.Maybe.Base.html#1382" class="Bound">A</a><a id="1432" class="Symbol">)</a> <a id="1434" class="Symbol">→</a> <a id="1436" href="Data.Maybe.Base.html#1394" class="Bound">B</a> <a id="1438" class="Symbol">(</a><a id="1439" href="Agda.Builtin.Maybe.html#156" class="InductiveConstructor">just</a> <a id="1444" href="Data.Maybe.Base.html#1427" class="Bound">x</a><a id="1445" class="Symbol">))</a> <a id="1448" class="Symbol">→</a> <a id="1450" href="Data.Maybe.Base.html#1394" class="Bound">B</a> <a id="1452" href="Agda.Builtin.Maybe.html#177" class="InductiveConstructor">nothing</a> <a id="1460" class="Symbol">→</a> <a id="1462" class="Symbol">(</a><a id="1463" href="Data.Maybe.Base.html#1463" class="Bound">x</a> <a id="1465" class="Symbol">:</a> <a id="1467" href="Agda.Builtin.Maybe.html#118" class="Datatype">Maybe</a> <a id="1473" href="Data.Maybe.Base.html#1382" class="Bound">A</a><a id="1474" class="Symbol">)</a> <a id="1476" class="Symbol">→</a> <a id="1478" href="Data.Maybe.Base.html#1394" class="Bound">B</a> <a id="1480" href="Data.Maybe.Base.html#1463" class="Bound">x</a>
|
|||
|
<a id="1482" href="Data.Maybe.Base.html#1371" class="Function">maybe</a> <a id="1488" href="Data.Maybe.Base.html#1488" class="Bound">j</a> <a id="1490" href="Data.Maybe.Base.html#1490" class="Bound">n</a> <a id="1492" class="Symbol">(</a><a id="1493" href="Agda.Builtin.Maybe.html#156" class="InductiveConstructor">just</a> <a id="1498" href="Data.Maybe.Base.html#1498" class="Bound">x</a><a id="1499" class="Symbol">)</a> <a id="1501" class="Symbol">=</a> <a id="1503" href="Data.Maybe.Base.html#1488" class="Bound">j</a> <a id="1505" href="Data.Maybe.Base.html#1498" class="Bound">x</a>
|
|||
|
<a id="1507" href="Data.Maybe.Base.html#1371" class="Function">maybe</a> <a id="1513" href="Data.Maybe.Base.html#1513" class="Bound">j</a> <a id="1515" href="Data.Maybe.Base.html#1515" class="Bound">n</a> <a id="1517" href="Agda.Builtin.Maybe.html#177" class="InductiveConstructor">nothing</a> <a id="1526" class="Symbol">=</a> <a id="1528" href="Data.Maybe.Base.html#1515" class="Bound">n</a>
|
|||
|
|
|||
|
<a id="1531" class="Comment">-- A non-dependent eliminator.</a>
|
|||
|
|
|||
|
<a id="maybe′"></a><a id="1563" href="Data.Maybe.Base.html#1563" class="Function">maybe′</a> <a id="1570" class="Symbol">:</a> <a id="1572" class="Symbol">(</a><a id="1573" href="Data.Maybe.Base.html#715" class="Generalizable">A</a> <a id="1575" class="Symbol">→</a> <a id="1577" href="Data.Maybe.Base.html#729" class="Generalizable">B</a><a id="1578" class="Symbol">)</a> <a id="1580" class="Symbol">→</a> <a id="1582" href="Data.Maybe.Base.html#729" class="Generalizable">B</a> <a id="1584" class="Symbol">→</a> <a id="1586" href="Agda.Builtin.Maybe.html#118" class="Datatype">Maybe</a> <a id="1592" href="Data.Maybe.Base.html#715" class="Generalizable">A</a> <a id="1594" class="Symbol">→</a> <a id="1596" href="Data.Maybe.Base.html#729" class="Generalizable">B</a>
|
|||
|
<a id="1598" href="Data.Maybe.Base.html#1563" class="Function">maybe′</a> <a id="1605" class="Symbol">=</a> <a id="1607" href="Data.Maybe.Base.html#1371" class="Function">maybe</a>
|
|||
|
|
|||
|
<a id="1614" class="Comment">-- A defaulting mechanism</a>
|
|||
|
|
|||
|
<a id="fromMaybe"></a><a id="1641" href="Data.Maybe.Base.html#1641" class="Function">fromMaybe</a> <a id="1651" class="Symbol">:</a> <a id="1653" href="Data.Maybe.Base.html#715" class="Generalizable">A</a> <a id="1655" class="Symbol">→</a> <a id="1657" href="Agda.Builtin.Maybe.html#118" class="Datatype">Maybe</a> <a id="1663" href="Data.Maybe.Base.html#715" class="Generalizable">A</a> <a id="1665" class="Symbol">→</a> <a id="1667" href="Data.Maybe.Base.html#715" class="Generalizable">A</a>
|
|||
|
<a id="1669" href="Data.Maybe.Base.html#1641" class="Function">fromMaybe</a> <a id="1679" class="Symbol">=</a> <a id="1681" href="Data.Maybe.Base.html#1563" class="Function">maybe′</a> <a id="1688" href="Function.Base.html#624" class="Function">id</a>
|
|||
|
|
|||
|
<a id="1692" class="Comment">-- A safe variant of "fromJust". If the value is nothing, then the</a>
|
|||
|
<a id="1759" class="Comment">-- return type is the unit type.</a>
|
|||
|
|
|||
|
<a id="1793" class="Keyword">module</a> <a id="1800" href="Data.Maybe.Base.html#1800" class="Module">_</a> <a id="1802" class="Symbol">{</a><a id="1803" href="Data.Maybe.Base.html#1803" class="Bound">a</a><a id="1804" class="Symbol">}</a> <a id="1806" class="Symbol">{</a><a id="1807" href="Data.Maybe.Base.html#1807" class="Bound">A</a> <a id="1809" class="Symbol">:</a> <a id="1811" href="Agda.Primitive.html#320" class="Primitive">Set</a> <a id="1815" href="Data.Maybe.Base.html#1803" class="Bound">a</a><a id="1816" class="Symbol">}</a> <a id="1818" class="Keyword">where</a>
|
|||
|
|
|||
|
<a id="1827" href="Data.Maybe.Base.html#1827" class="Function">From-just</a> <a id="1837" class="Symbol">:</a> <a id="1839" href="Agda.Builtin.Maybe.html#118" class="Datatype">Maybe</a> <a id="1845" href="Data.Maybe.Base.html#1807" class="Bound">A</a> <a id="1847" class="Symbol">→</a> <a id="1849" href="Agda.Primitive.html#320" class="Primitive">Set</a> <a id="1853" href="Data.Maybe.Base.html#1803" class="Bound">a</a>
|
|||
|
<a id="1857" href="Data.Maybe.Base.html#1827" class="Function">From-just</a> <a id="1867" class="Symbol">(</a><a id="1868" href="Agda.Builtin.Maybe.html#156" class="InductiveConstructor">just</a> <a id="1873" class="Symbol">_)</a> <a id="1876" class="Symbol">=</a> <a id="1878" href="Data.Maybe.Base.html#1807" class="Bound">A</a>
|
|||
|
<a id="1882" href="Data.Maybe.Base.html#1827" class="Function">From-just</a> <a id="1892" href="Agda.Builtin.Maybe.html#177" class="InductiveConstructor">nothing</a> <a id="1901" class="Symbol">=</a> <a id="1903" href="Level.html#409" class="Record">Lift</a> <a id="1908" href="Data.Maybe.Base.html#1803" class="Bound">a</a> <a id="1910" href="Agda.Builtin.Unit.html#158" class="Record">⊤</a>
|
|||
|
|
|||
|
<a id="1915" href="Data.Maybe.Base.html#1915" class="Function">from-just</a> <a id="1925" class="Symbol">:</a> <a id="1927" class="Symbol">(</a><a id="1928" href="Data.Maybe.Base.html#1928" class="Bound">x</a> <a id="1930" class="Symbol">:</a> <a id="1932" href="Agda.Builtin.Maybe.html#118" class="Datatype">Maybe</a> <a id="1938" href="Data.Maybe.Base.html#1807" class="Bound">A</a><a id="1939" class="Symbol">)</a> <a id="1941" class="Symbol">→</a> <a id="1943" href="Data.Maybe.Base.html#1827" class="Function">From-just</a> <a id="1953" href="Data.Maybe.Base.html#1928" class="Bound">x</a>
|
|||
|
<a id="1957" href="Data.Maybe.Base.html#1915" class="Function">from-just</a> <a id="1967" class="Symbol">(</a><a id="1968" href="Agda.Builtin.Maybe.html#156" class="InductiveConstructor">just</a> <a id="1973" href="Data.Maybe.Base.html#1973" class="Bound">x</a><a id="1974" class="Symbol">)</a> <a id="1976" class="Symbol">=</a> <a id="1978" href="Data.Maybe.Base.html#1973" class="Bound">x</a>
|
|||
|
<a id="1982" href="Data.Maybe.Base.html#1915" class="Function">from-just</a> <a id="1992" href="Agda.Builtin.Maybe.html#177" class="InductiveConstructor">nothing</a> <a id="2001" class="Symbol">=</a> <a id="2003" class="Symbol">_</a>
|
|||
|
|
|||
|
<a id="2006" class="Comment">-- Functoriality: map</a>
|
|||
|
|
|||
|
<a id="map"></a><a id="2029" href="Data.Maybe.Base.html#2029" class="Function">map</a> <a id="2033" class="Symbol">:</a> <a id="2035" class="Symbol">(</a><a id="2036" href="Data.Maybe.Base.html#715" class="Generalizable">A</a> <a id="2038" class="Symbol">→</a> <a id="2040" href="Data.Maybe.Base.html#729" class="Generalizable">B</a><a id="2041" class="Symbol">)</a> <a id="2043" class="Symbol">→</a> <a id="2045" href="Agda.Builtin.Maybe.html#118" class="Datatype">Maybe</a> <a id="2051" href="Data.Maybe.Base.html#715" class="Generalizable">A</a> <a id="2053" class="Symbol">→</a> <a id="2055" href="Agda.Builtin.Maybe.html#118" class="Datatype">Maybe</a> <a id="2061" href="Data.Maybe.Base.html#729" class="Generalizable">B</a>
|
|||
|
<a id="2063" href="Data.Maybe.Base.html#2029" class="Function">map</a> <a id="2067" href="Data.Maybe.Base.html#2067" class="Bound">f</a> <a id="2069" class="Symbol">=</a> <a id="2071" href="Data.Maybe.Base.html#1371" class="Function">maybe</a> <a id="2077" class="Symbol">(</a><a id="2078" href="Agda.Builtin.Maybe.html#156" class="InductiveConstructor">just</a> <a id="2083" href="Function.Base.html#1040" class="Function Operator">∘</a> <a id="2085" href="Data.Maybe.Base.html#2067" class="Bound">f</a><a id="2086" class="Symbol">)</a> <a id="2088" href="Agda.Builtin.Maybe.html#177" class="InductiveConstructor">nothing</a>
|
|||
|
|
|||
|
<a id="2097" class="Comment">-- Applicative: ap</a>
|
|||
|
|
|||
|
<a id="ap"></a><a id="2117" href="Data.Maybe.Base.html#2117" class="Function">ap</a> <a id="2120" class="Symbol">:</a> <a id="2122" href="Agda.Builtin.Maybe.html#118" class="Datatype">Maybe</a> <a id="2128" class="Symbol">(</a><a id="2129" href="Data.Maybe.Base.html#715" class="Generalizable">A</a> <a id="2131" class="Symbol">→</a> <a id="2133" href="Data.Maybe.Base.html#729" class="Generalizable">B</a><a id="2134" class="Symbol">)</a> <a id="2136" class="Symbol">→</a> <a id="2138" href="Agda.Builtin.Maybe.html#118" class="Datatype">Maybe</a> <a id="2144" href="Data.Maybe.Base.html#715" class="Generalizable">A</a> <a id="2146" class="Symbol">→</a> <a id="2148" href="Agda.Builtin.Maybe.html#118" class="Datatype">Maybe</a> <a id="2154" href="Data.Maybe.Base.html#729" class="Generalizable">B</a>
|
|||
|
<a id="2156" href="Data.Maybe.Base.html#2117" class="Function">ap</a> <a id="2159" href="Agda.Builtin.Maybe.html#177" class="InductiveConstructor">nothing</a> <a id="2168" class="Symbol">=</a> <a id="2170" href="Function.Base.html#645" class="Function">const</a> <a id="2176" href="Agda.Builtin.Maybe.html#177" class="InductiveConstructor">nothing</a>
|
|||
|
<a id="2184" href="Data.Maybe.Base.html#2117" class="Function">ap</a> <a id="2187" class="Symbol">(</a><a id="2188" href="Agda.Builtin.Maybe.html#156" class="InductiveConstructor">just</a> <a id="2193" href="Data.Maybe.Base.html#2193" class="Bound">f</a><a id="2194" class="Symbol">)</a> <a id="2196" class="Symbol">=</a> <a id="2198" href="Data.Maybe.Base.html#2029" class="Function">map</a> <a id="2202" href="Data.Maybe.Base.html#2193" class="Bound">f</a>
|
|||
|
|
|||
|
<a id="2205" class="Comment">-- Monad: bind</a>
|
|||
|
|
|||
|
<a id="2221" class="Keyword">infixl</a> <a id="2228" class="Number">1</a> <a id="2230" href="Data.Maybe.Base.html#2236" class="Function Operator">_>>=_</a>
|
|||
|
<a id="_>>=_"></a><a id="2236" href="Data.Maybe.Base.html#2236" class="Function Operator">_>>=_</a> <a id="2242" class="Symbol">:</a> <a id="2244" href="Agda.Builtin.Maybe.html#118" class="Datatype">Maybe</a> <a id="2250" href="Data.Maybe.Base.html#715" class="Generalizable">A</a> <a id="2252" class="Symbol">→</a> <a id="2254" class="Symbol">(</a><a id="2255" href="Data.Maybe.Base.html#715" class="Generalizable">A</a> <a id="2257" class="Symbol">→</a> <a id="2259" href="Agda.Builtin.Maybe.html#118" class="Datatype">Maybe</a> <a id="2265" href="Data.Maybe.Base.html#729" class="Generalizable">B</a><a id="2266" class="Symbol">)</a> <a id="2268" class="Symbol">→</a> <a id="2270" href="Agda.Builtin.Maybe.html#118" class="Datatype">Maybe</a> <a id="2276" href="Data.Maybe.Base.html#729" class="Generalizable">B</a>
|
|||
|
<a id="2278" href="Agda.Builtin.Maybe.html#177" class="InductiveConstructor">nothing</a> <a id="2286" href="Data.Maybe.Base.html#2236" class="Function Operator">>>=</a> <a id="2290" href="Data.Maybe.Base.html#2290" class="Bound">f</a> <a id="2292" class="Symbol">=</a> <a id="2294" href="Agda.Builtin.Maybe.html#177" class="InductiveConstructor">nothing</a>
|
|||
|
<a id="2302" href="Agda.Builtin.Maybe.html#156" class="InductiveConstructor">just</a> <a id="2307" href="Data.Maybe.Base.html#2307" class="Bound">a</a> <a id="2310" href="Data.Maybe.Base.html#2236" class="Function Operator">>>=</a> <a id="2314" href="Data.Maybe.Base.html#2314" class="Bound">f</a> <a id="2316" class="Symbol">=</a> <a id="2318" href="Data.Maybe.Base.html#2314" class="Bound">f</a> <a id="2320" href="Data.Maybe.Base.html#2307" class="Bound">a</a>
|
|||
|
|
|||
|
<a id="2323" class="Comment">-- Alternative: <∣></a>
|
|||
|
|
|||
|
<a id="_<∣>_"></a><a id="2344" href="Data.Maybe.Base.html#2344" class="Function Operator">_<∣>_</a> <a id="2350" class="Symbol">:</a> <a id="2352" href="Agda.Builtin.Maybe.html#118" class="Datatype">Maybe</a> <a id="2358" href="Data.Maybe.Base.html#715" class="Generalizable">A</a> <a id="2360" class="Symbol">→</a> <a id="2362" href="Agda.Builtin.Maybe.html#118" class="Datatype">Maybe</a> <a id="2368" href="Data.Maybe.Base.html#715" class="Generalizable">A</a> <a id="2370" class="Symbol">→</a> <a id="2372" href="Agda.Builtin.Maybe.html#118" class="Datatype">Maybe</a> <a id="2378" href="Data.Maybe.Base.html#715" class="Generalizable">A</a>
|
|||
|
<a id="2380" href="Agda.Builtin.Maybe.html#156" class="InductiveConstructor">just</a> <a id="2385" href="Data.Maybe.Base.html#2385" class="Bound">x</a> <a id="2388" href="Data.Maybe.Base.html#2344" class="Function Operator"><∣></a> <a id="2392" href="Data.Maybe.Base.html#2392" class="Bound">my</a> <a id="2395" class="Symbol">=</a> <a id="2397" href="Agda.Builtin.Maybe.html#156" class="InductiveConstructor">just</a> <a id="2402" href="Data.Maybe.Base.html#2385" class="Bound">x</a>
|
|||
|
<a id="2404" href="Agda.Builtin.Maybe.html#177" class="InductiveConstructor">nothing</a> <a id="2412" href="Data.Maybe.Base.html#2344" class="Function Operator"><∣></a> <a id="2416" href="Data.Maybe.Base.html#2416" class="Bound">my</a> <a id="2419" class="Symbol">=</a> <a id="2421" href="Data.Maybe.Base.html#2416" class="Bound">my</a>
|
|||
|
|
|||
|
<a id="2425" class="Comment">-- Just when the boolean is true</a>
|
|||
|
|
|||
|
<a id="when"></a><a id="2459" href="Data.Maybe.Base.html#2459" class="Function">when</a> <a id="2464" class="Symbol">:</a> <a id="2466" href="Agda.Builtin.Bool.html#156" class="Datatype">Bool</a> <a id="2471" class="Symbol">→</a> <a id="2473" href="Data.Maybe.Base.html#715" class="Generalizable">A</a> <a id="2475" class="Symbol">→</a> <a id="2477" href="Agda.Builtin.Maybe.html#118" class="Datatype">Maybe</a> <a id="2483" href="Data.Maybe.Base.html#715" class="Generalizable">A</a>
|
|||
|
<a id="2485" href="Data.Maybe.Base.html#2459" class="Function">when</a> <a id="2490" href="Data.Maybe.Base.html#2490" class="Bound">b</a> <a id="2492" href="Data.Maybe.Base.html#2492" class="Bound">c</a> <a id="2494" class="Symbol">=</a> <a id="2496" href="Data.Maybe.Base.html#2029" class="Function">map</a> <a id="2500" class="Symbol">(</a><a id="2501" href="Function.Base.html#645" class="Function">const</a> <a id="2507" href="Data.Maybe.Base.html#2492" class="Bound">c</a><a id="2508" class="Symbol">)</a> <a id="2510" class="Symbol">(</a><a id="2511" href="Data.Maybe.Base.html#1005" class="Function">boolToMaybe</a> <a id="2523" href="Data.Maybe.Base.html#2490" class="Bound">b</a><a id="2524" class="Symbol">)</a>
|
|||
|
|
|||
|
<a id="2527" class="Comment">------------------------------------------------------------------------</a>
|
|||
|
<a id="2600" class="Comment">-- Aligning and zipping</a>
|
|||
|
|
|||
|
<a id="alignWith"></a><a id="2625" href="Data.Maybe.Base.html#2625" class="Function">alignWith</a> <a id="2635" class="Symbol">:</a> <a id="2637" class="Symbol">(</a><a id="2638" href="Data.These.Base.html#537" class="Datatype">These</a> <a id="2644" href="Data.Maybe.Base.html#715" class="Generalizable">A</a> <a id="2646" href="Data.Maybe.Base.html#729" class="Generalizable">B</a> <a id="2648" class="Symbol">→</a> <a id="2650" href="Data.Maybe.Base.html#743" class="Generalizable">C</a><a id="2651" class="Symbol">)</a> <a id="2653" class="Symbol">→</a> <a id="2655" href="Agda.Builtin.Maybe.html#118" class="Datatype">Maybe</a> <a id="2661" href="Data.Maybe.Base.html#715" class="Generalizable">A</a> <a id="2663" class="Symbol">→</a> <a id="2665" href="Agda.Builtin.Maybe.html#118" class="Datatype">Maybe</a> <a id="2671" href="Data.Maybe.Base.html#729" class="Generalizable">B</a> <a id="2673" class="Symbol">→</a> <a id="2675" href="Agda.Builtin.Maybe.html#118" class="Datatype">Maybe</a> <a id="2681" href="Data.Maybe.Base.html#743" class="Generalizable">C</a>
|
|||
|
<a id="2683" href="Data.Maybe.Base.html#2625" class="Function">alignWith</a> <a id="2693" href="Data.Maybe.Base.html#2693" class="Bound">f</a> <a id="2695" class="Symbol">(</a><a id="2696" href="Agda.Builtin.Maybe.html#156" class="InductiveConstructor">just</a> <a id="2701" href="Data.Maybe.Base.html#2701" class="Bound">a</a><a id="2702" class="Symbol">)</a> <a id="2704" class="Symbol">(</a><a id="2705" href="Agda.Builtin.Maybe.html#156" class="InductiveConstructor">just</a> <a id="2710" href="Data.Maybe.Base.html#2710" class="Bound">b</a><a id="2711" class="Symbol">)</a> <a id="2713" class="Symbol">=</a> <a id="2715" href="Agda.Builtin.Maybe.html#156" class="InductiveConstructor">just</a> <a id="2720" class="Symbol">(</a><a id="2721" href="Data.Maybe.Base.html#2693" class="Bound">f</a> <a id="2723" class="Symbol">(</a><a id="2724" href="Data.These.Base.html#651" class="InductiveConstructor">these</a> <a id="2730" href="Data.Maybe.Base.html#2701" class="Bound">a</a> <a id="2732" href="Data.Maybe.Base.html#2710" class="Bound">b</a><a id="2733" class="Symbol">))</a>
|
|||
|
<a id="2736" href="Data.Maybe.Base.html#2625" class="Function">alignWith</a> <a id="2746" href="Data.Maybe.Base.html#2746" class="Bound">f</a> <a id="2748" class="Symbol">(</a><a id="2749" href="Agda.Builtin.Maybe.html#156" class="InductiveConstructor">just</a> <a id="2754" href="Data.Maybe.Base.html#2754" class="Bound">a</a><a id="2755" class="Symbol">)</a> <a id="2757" href="Agda.Builtin.Maybe.html#177" class="InductiveConstructor">nothing</a> <a id="2766" class="Symbol">=</a> <a id="2768" href="Agda.Builtin.Maybe.html#156" class="InductiveConstructor">just</a> <a id="2773" class="Symbol">(</a><a id="2774" href="Data.Maybe.Base.html#2746" class="Bound">f</a> <a id="2776" class="Symbol">(</a><a id="2777" href="Data.These.Base.html#595" class="InductiveConstructor">this</a> <a id="2782" href="Data.Maybe.Base.html#2754" class="Bound">a</a><a id="2783" class="Symbol">))</a>
|
|||
|
<a id="2786" href="Data.Maybe.Base.html#2625" class="Function">alignWith</a> <a id="2796" href="Data.Maybe.Base.html#2796" class="Bound">f</a> <a id="2798" href="Agda.Builtin.Maybe.html#177" class="InductiveConstructor">nothing</a> <a id="2807" class="Symbol">(</a><a id="2808" href="Agda.Builtin.Maybe.html#156" class="InductiveConstructor">just</a> <a id="2813" href="Data.Maybe.Base.html#2813" class="Bound">b</a><a id="2814" class="Symbol">)</a> <a id="2816" class="Symbol">=</a> <a id="2818" href="Agda.Builtin.Maybe.html#156" class="InductiveConstructor">just</a> <a id="2823" class="Symbol">(</a><a id="2824" href="Data.Maybe.Base.html#2796" class="Bound">f</a> <a id="2826" class="Symbol">(</a><a id="2827" href="Data.These.Base.html#623" class="InductiveConstructor">that</a> <a id="2832" href="Data.Maybe.Base.html#2813" class="Bound">b</a><a id="2833" class="Symbol">))</a>
|
|||
|
<a id="2836" href="Data.Maybe.Base.html#2625" class="Function">alignWith</a> <a id="2846" href="Data.Maybe.Base.html#2846" class="Bound">f</a> <a id="2848" href="Agda.Builtin.Maybe.html#177" class="InductiveConstructor">nothing</a> <a id="2857" href="Agda.Builtin.Maybe.html#177" class="InductiveConstructor">nothing</a> <a id="2866" class="Symbol">=</a> <a id="2868" href="Agda.Builtin.Maybe.html#177" class="InductiveConstructor">nothing</a>
|
|||
|
|
|||
|
<a id="zipWith"></a><a id="2877" href="Data.Maybe.Base.html#2877" class="Function">zipWith</a> <a id="2885" class="Symbol">:</a> <a id="2887" class="Symbol">(</a><a id="2888" href="Data.Maybe.Base.html#715" class="Generalizable">A</a> <a id="2890" class="Symbol">→</a> <a id="2892" href="Data.Maybe.Base.html#729" class="Generalizable">B</a> <a id="2894" class="Symbol">→</a> <a id="2896" href="Data.Maybe.Base.html#743" class="Generalizable">C</a><a id="2897" class="Symbol">)</a> <a id="2899" class="Symbol">→</a> <a id="2901" href="Agda.Builtin.Maybe.html#118" class="Datatype">Maybe</a> <a id="2907" href="Data.Maybe.Base.html#715" class="Generalizable">A</a> <a id="2909" class="Symbol">→</a> <a id="2911" href="Agda.Builtin.Maybe.html#118" class="Datatype">Maybe</a> <a id="2917" href="Data.Maybe.Base.html#729" class="Generalizable">B</a> <a id="2919" class="Symbol">→</a> <a id="2921" href="Agda.Builtin.Maybe.html#118" class="Datatype">Maybe</a> <a id="2927" href="Data.Maybe.Base.html#743" class="Generalizable">C</a>
|
|||
|
<a id="2929" href="Data.Maybe.Base.html#2877" class="Function">zipWith</a> <a id="2937" href="Data.Maybe.Base.html#2937" class="Bound">f</a> <a id="2939" class="Symbol">(</a><a id="2940" href="Agda.Builtin.Maybe.html#156" class="InductiveConstructor">just</a> <a id="2945" href="Data.Maybe.Base.html#2945" class="Bound">a</a><a id="2946" class="Symbol">)</a> <a id="2948" class="Symbol">(</a><a id="2949" href="Agda.Builtin.Maybe.html#156" class="InductiveConstructor">just</a> <a id="2954" href="Data.Maybe.Base.html#2954" class="Bound">b</a><a id="2955" class="Symbol">)</a> <a id="2957" class="Symbol">=</a> <a id="2959" href="Agda.Builtin.Maybe.html#156" class="InductiveConstructor">just</a> <a id="2964" class="Symbol">(</a><a id="2965" href="Data.Maybe.Base.html#2937" class="Bound">f</a> <a id="2967" href="Data.Maybe.Base.html#2945" class="Bound">a</a> <a id="2969" href="Data.Maybe.Base.html#2954" class="Bound">b</a><a id="2970" class="Symbol">)</a>
|
|||
|
<a id="2972" href="Data.Maybe.Base.html#2877" class="CatchallClause Function">zipWith</a><a id="2979" class="CatchallClause"> </a><a id="2980" class="CatchallClause Symbol">_</a><a id="2981" class="CatchallClause"> </a><a id="2982" class="CatchallClause Symbol">_</a><a id="2983" class="CatchallClause"> </a><a id="2991" class="CatchallClause Symbol">_</a> <a id="3000" class="Symbol">=</a> <a id="3002" href="Agda.Builtin.Maybe.html#177" class="InductiveConstructor">nothing</a>
|
|||
|
|
|||
|
<a id="align"></a><a id="3011" href="Data.Maybe.Base.html#3011" class="Function">align</a> <a id="3017" class="Symbol">:</a> <a id="3019" href="Agda.Builtin.Maybe.html#118" class="Datatype">Maybe</a> <a id="3025" href="Data.Maybe.Base.html#715" class="Generalizable">A</a> <a id="3027" class="Symbol">→</a> <a id="3029" href="Agda.Builtin.Maybe.html#118" class="Datatype">Maybe</a> <a id="3035" href="Data.Maybe.Base.html#729" class="Generalizable">B</a> <a id="3037" class="Symbol">→</a> <a id="3039" href="Agda.Builtin.Maybe.html#118" class="Datatype">Maybe</a> <a id="3045" class="Symbol">(</a><a id="3046" href="Data.These.Base.html#537" class="Datatype">These</a> <a id="3052" href="Data.Maybe.Base.html#715" class="Generalizable">A</a> <a id="3054" href="Data.Maybe.Base.html#729" class="Generalizable">B</a><a id="3055" class="Symbol">)</a>
|
|||
|
<a id="3057" href="Data.Maybe.Base.html#3011" class="Function">align</a> <a id="3063" class="Symbol">=</a> <a id="3065" href="Data.Maybe.Base.html#2625" class="Function">alignWith</a> <a id="3075" href="Function.Base.html#624" class="Function">id</a>
|
|||
|
|
|||
|
<a id="zip"></a><a id="3079" href="Data.Maybe.Base.html#3079" class="Function">zip</a> <a id="3083" class="Symbol">:</a> <a id="3085" href="Agda.Builtin.Maybe.html#118" class="Datatype">Maybe</a> <a id="3091" href="Data.Maybe.Base.html#715" class="Generalizable">A</a> <a id="3093" class="Symbol">→</a> <a id="3095" href="Agda.Builtin.Maybe.html#118" class="Datatype">Maybe</a> <a id="3101" href="Data.Maybe.Base.html#729" class="Generalizable">B</a> <a id="3103" class="Symbol">→</a> <a id="3105" href="Agda.Builtin.Maybe.html#118" class="Datatype">Maybe</a> <a id="3111" class="Symbol">(</a><a id="3112" href="Data.Maybe.Base.html#715" class="Generalizable">A</a> <a id="3114" href="Data.Product.html#1176" class="Function Operator">×</a> <a id="3116" href="Data.Maybe.Base.html#729" class="Generalizable">B</a><a id="3117" class="Symbol">)</a>
|
|||
|
<a id="3119" href="Data.Maybe.Base.html#3079" class="Function">zip</a> <a id="3123" class="Symbol">=</a> <a id="3125" href="Data.Maybe.Base.html#2877" class="Function">zipWith</a> <a id="3133" href="Agda.Builtin.Sigma.html#218" class="InductiveConstructor Operator">_,_</a>
|
|||
|
|
|||
|
<a id="3138" class="Comment">------------------------------------------------------------------------</a>
|
|||
|
<a id="3211" class="Comment">-- Injections.</a>
|
|||
|
|
|||
|
<a id="thisM"></a><a id="3227" href="Data.Maybe.Base.html#3227" class="Function">thisM</a> <a id="3233" class="Symbol">:</a> <a id="3235" href="Data.Maybe.Base.html#715" class="Generalizable">A</a> <a id="3237" class="Symbol">→</a> <a id="3239" href="Agda.Builtin.Maybe.html#118" class="Datatype">Maybe</a> <a id="3245" href="Data.Maybe.Base.html#729" class="Generalizable">B</a> <a id="3247" class="Symbol">→</a> <a id="3249" href="Data.These.Base.html#537" class="Datatype">These</a> <a id="3255" href="Data.Maybe.Base.html#715" class="Generalizable">A</a> <a id="3257" href="Data.Maybe.Base.html#729" class="Generalizable">B</a>
|
|||
|
<a id="3259" href="Data.Maybe.Base.html#3227" class="Function">thisM</a> <a id="3265" href="Data.Maybe.Base.html#3265" class="Bound">a</a> <a id="3267" class="Symbol">=</a> <a id="3269" href="Data.Maybe.Base.html#1563" class="Function">maybe′</a> <a id="3276" class="Symbol">(</a><a id="3277" href="Data.These.Base.html#651" class="InductiveConstructor">these</a> <a id="3283" href="Data.Maybe.Base.html#3265" class="Bound">a</a><a id="3284" class="Symbol">)</a> <a id="3286" class="Symbol">(</a><a id="3287" href="Data.These.Base.html#595" class="InductiveConstructor">this</a> <a id="3292" href="Data.Maybe.Base.html#3265" class="Bound">a</a><a id="3293" class="Symbol">)</a>
|
|||
|
|
|||
|
<a id="thatM"></a><a id="3296" href="Data.Maybe.Base.html#3296" class="Function">thatM</a> <a id="3302" class="Symbol">:</a> <a id="3304" href="Agda.Builtin.Maybe.html#118" class="Datatype">Maybe</a> <a id="3310" href="Data.Maybe.Base.html#715" class="Generalizable">A</a> <a id="3312" class="Symbol">→</a> <a id="3314" href="Data.Maybe.Base.html#729" class="Generalizable">B</a> <a id="3316" class="Symbol">→</a> <a id="3318" href="Data.These.Base.html#537" class="Datatype">These</a> <a id="3324" href="Data.Maybe.Base.html#715" class="Generalizable">A</a> <a id="3326" href="Data.Maybe.Base.html#729" class="Generalizable">B</a>
|
|||
|
<a id="3328" href="Data.Maybe.Base.html#3296" class="Function">thatM</a> <a id="3334" class="Symbol">=</a> <a id="3336" href="Data.Maybe.Base.html#1563" class="Function">maybe′</a> <a id="3343" href="Data.These.Base.html#651" class="InductiveConstructor">these</a> <a id="3349" href="Data.These.Base.html#623" class="InductiveConstructor">that</a>
|
|||
|
</pre></body></html>
|