mirror of
https://git8.cs.fau.de/theses/bsc-leon-vatthauer.git
synced 2024-05-31 07:28:34 +02:00
141 lines
No EOL
38 KiB
HTML
141 lines
No EOL
38 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#173" class="Datatype">Bool</a><a id="412" class="Symbol">;</a> <a id="414" href="Agda.Builtin.Bool.html#198" class="InductiveConstructor">true</a><a id="418" class="Symbol">;</a> <a id="420" href="Agda.Builtin.Bool.html#192" 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#175" 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.Base.html" class="Module">Data.Product.Base</a> <a id="560" class="Symbol">as</a> <a id="563" class="Module">Prod</a> <a id="568" class="Keyword">using</a> <a id="574" class="Symbol">(</a><a id="575" href="Data.Product.Base.html#1618" class="Function Operator">_×_</a><a id="578" class="Symbol">;</a> <a id="580" href="Agda.Builtin.Sigma.html#235" class="InductiveConstructor Operator">_,_</a><a id="583" class="Symbol">)</a>
|
||
<a id="585" class="Keyword">open</a> <a id="590" class="Keyword">import</a> <a id="597" href="Function.Base.html" class="Module">Function.Base</a>
|
||
<a id="611" class="Keyword">open</a> <a id="616" class="Keyword">import</a> <a id="623" href="Relation.Nullary.Reflects.html" class="Module">Relation.Nullary.Reflects</a>
|
||
<a id="649" class="Keyword">open</a> <a id="654" class="Keyword">import</a> <a id="661" href="Relation.Nullary.Decidable.Core.html" class="Module">Relation.Nullary.Decidable.Core</a>
|
||
|
||
<a id="694" class="Keyword">private</a>
|
||
<a id="704" class="Keyword">variable</a>
|
||
<a id="717" href="Data.Maybe.Base.html#717" class="Generalizable">a</a> <a id="719" href="Data.Maybe.Base.html#719" class="Generalizable">b</a> <a id="721" href="Data.Maybe.Base.html#721" class="Generalizable">c</a> <a id="723" class="Symbol">:</a> <a id="725" href="Agda.Primitive.html#742" class="Postulate">Level</a>
|
||
<a id="735" href="Data.Maybe.Base.html#735" class="Generalizable">A</a> <a id="737" class="Symbol">:</a> <a id="739" href="Agda.Primitive.html#388" class="Primitive">Set</a> <a id="743" href="Data.Maybe.Base.html#717" class="Generalizable">a</a>
|
||
<a id="749" href="Data.Maybe.Base.html#749" class="Generalizable">B</a> <a id="751" class="Symbol">:</a> <a id="753" href="Agda.Primitive.html#388" class="Primitive">Set</a> <a id="757" href="Data.Maybe.Base.html#719" class="Generalizable">b</a>
|
||
<a id="763" href="Data.Maybe.Base.html#763" class="Generalizable">C</a> <a id="765" class="Symbol">:</a> <a id="767" href="Agda.Primitive.html#388" class="Primitive">Set</a> <a id="771" href="Data.Maybe.Base.html#721" class="Generalizable">c</a>
|
||
|
||
<a id="774" class="Comment">------------------------------------------------------------------------</a>
|
||
<a id="847" class="Comment">-- Definition</a>
|
||
|
||
<a id="862" class="Keyword">open</a> <a id="867" class="Keyword">import</a> <a id="874" href="Agda.Builtin.Maybe.html" class="Module">Agda.Builtin.Maybe</a> <a id="893" class="Keyword">public</a>
|
||
<a id="902" class="Keyword">using</a> <a id="908" class="Symbol">(</a><a id="909" href="Agda.Builtin.Maybe.html#135" class="Datatype">Maybe</a><a id="914" class="Symbol">;</a> <a id="916" href="Agda.Builtin.Maybe.html#173" class="InductiveConstructor">just</a><a id="920" class="Symbol">;</a> <a id="922" href="Agda.Builtin.Maybe.html#194" class="InductiveConstructor">nothing</a><a id="929" class="Symbol">)</a>
|
||
|
||
<a id="932" class="Comment">------------------------------------------------------------------------</a>
|
||
<a id="1005" class="Comment">-- Some operations</a>
|
||
|
||
<a id="boolToMaybe"></a><a id="1025" href="Data.Maybe.Base.html#1025" class="Function">boolToMaybe</a> <a id="1037" class="Symbol">:</a> <a id="1039" href="Agda.Builtin.Bool.html#173" class="Datatype">Bool</a> <a id="1044" class="Symbol">→</a> <a id="1046" href="Agda.Builtin.Maybe.html#135" class="Datatype">Maybe</a> <a id="1052" href="Agda.Builtin.Unit.html#175" class="Record">⊤</a>
|
||
<a id="1054" href="Data.Maybe.Base.html#1025" class="Function">boolToMaybe</a> <a id="1066" href="Agda.Builtin.Bool.html#198" class="InductiveConstructor">true</a> <a id="1072" class="Symbol">=</a> <a id="1074" href="Agda.Builtin.Maybe.html#173" class="InductiveConstructor">just</a> <a id="1079" class="Symbol">_</a>
|
||
<a id="1081" href="Data.Maybe.Base.html#1025" class="Function">boolToMaybe</a> <a id="1093" href="Agda.Builtin.Bool.html#192" class="InductiveConstructor">false</a> <a id="1099" class="Symbol">=</a> <a id="1101" href="Agda.Builtin.Maybe.html#194" class="InductiveConstructor">nothing</a>
|
||
|
||
<a id="is-just"></a><a id="1110" href="Data.Maybe.Base.html#1110" class="Function">is-just</a> <a id="1118" class="Symbol">:</a> <a id="1120" href="Agda.Builtin.Maybe.html#135" class="Datatype">Maybe</a> <a id="1126" href="Data.Maybe.Base.html#735" class="Generalizable">A</a> <a id="1128" class="Symbol">→</a> <a id="1130" href="Agda.Builtin.Bool.html#173" class="Datatype">Bool</a>
|
||
<a id="1135" href="Data.Maybe.Base.html#1110" class="Function">is-just</a> <a id="1143" class="Symbol">(</a><a id="1144" href="Agda.Builtin.Maybe.html#173" class="InductiveConstructor">just</a> <a id="1149" class="Symbol">_)</a> <a id="1152" class="Symbol">=</a> <a id="1154" href="Agda.Builtin.Bool.html#198" class="InductiveConstructor">true</a>
|
||
<a id="1159" href="Data.Maybe.Base.html#1110" class="Function">is-just</a> <a id="1167" href="Agda.Builtin.Maybe.html#194" class="InductiveConstructor">nothing</a> <a id="1176" class="Symbol">=</a> <a id="1178" href="Agda.Builtin.Bool.html#192" class="InductiveConstructor">false</a>
|
||
|
||
<a id="is-nothing"></a><a id="1185" href="Data.Maybe.Base.html#1185" class="Function">is-nothing</a> <a id="1196" class="Symbol">:</a> <a id="1198" href="Agda.Builtin.Maybe.html#135" class="Datatype">Maybe</a> <a id="1204" href="Data.Maybe.Base.html#735" class="Generalizable">A</a> <a id="1206" class="Symbol">→</a> <a id="1208" href="Agda.Builtin.Bool.html#173" class="Datatype">Bool</a>
|
||
<a id="1213" href="Data.Maybe.Base.html#1185" class="Function">is-nothing</a> <a id="1224" class="Symbol">=</a> <a id="1226" href="Data.Bool.Base.html#941" class="Function">not</a> <a id="1230" href="Function.Base.html#1115" class="Function Operator">∘</a> <a id="1232" href="Data.Maybe.Base.html#1110" class="Function">is-just</a>
|
||
|
||
<a id="decToMaybe"></a><a id="1241" href="Data.Maybe.Base.html#1241" class="Function">decToMaybe</a> <a id="1252" class="Symbol">:</a> <a id="1254" href="Relation.Nullary.Decidable.Core.html#1485" class="Record">Dec</a> <a id="1258" href="Data.Maybe.Base.html#735" class="Generalizable">A</a> <a id="1260" class="Symbol">→</a> <a id="1262" href="Agda.Builtin.Maybe.html#135" class="Datatype">Maybe</a> <a id="1268" href="Data.Maybe.Base.html#735" class="Generalizable">A</a>
|
||
<a id="1270" href="Data.Maybe.Base.html#1241" class="Function">decToMaybe</a> <a id="1281" class="Symbol">(</a> <a id="1283" href="Agda.Builtin.Bool.html#198" class="InductiveConstructor">true</a> <a id="1288" href="Relation.Nullary.Decidable.Core.html#1529" class="InductiveConstructor Operator">because</a> <a id="1296" href="Data.Maybe.Base.html#1296" class="Bound">[a]</a><a id="1299" class="Symbol">)</a> <a id="1301" class="Symbol">=</a> <a id="1303" href="Agda.Builtin.Maybe.html#173" class="InductiveConstructor">just</a> <a id="1308" class="Symbol">(</a><a id="1309" href="Relation.Nullary.Reflects.html#1582" class="Function">invert</a> <a id="1316" href="Data.Maybe.Base.html#1296" class="Bound">[a]</a><a id="1319" class="Symbol">)</a>
|
||
<a id="1321" href="Data.Maybe.Base.html#1241" class="Function">decToMaybe</a> <a id="1332" class="Symbol">(</a><a id="1333" href="Agda.Builtin.Bool.html#192" class="InductiveConstructor">false</a> <a id="1339" href="Relation.Nullary.Decidable.Core.html#1529" class="InductiveConstructor Operator">because</a> <a id="1348" class="Symbol">_</a> <a id="1350" class="Symbol">)</a> <a id="1352" class="Symbol">=</a> <a id="1354" href="Agda.Builtin.Maybe.html#194" class="InductiveConstructor">nothing</a>
|
||
|
||
<a id="1363" class="Comment">-- A dependent eliminator.</a>
|
||
|
||
<a id="maybe"></a><a id="1391" href="Data.Maybe.Base.html#1391" class="Function">maybe</a> <a id="1397" class="Symbol">:</a> <a id="1399" class="Symbol">∀</a> <a id="1401" class="Symbol">{</a><a id="1402" href="Data.Maybe.Base.html#1402" class="Bound">A</a> <a id="1404" class="Symbol">:</a> <a id="1406" href="Agda.Primitive.html#388" class="Primitive">Set</a> <a id="1410" href="Data.Maybe.Base.html#717" class="Generalizable">a</a><a id="1411" class="Symbol">}</a> <a id="1413" class="Symbol">{</a><a id="1414" href="Data.Maybe.Base.html#1414" class="Bound">B</a> <a id="1416" class="Symbol">:</a> <a id="1418" href="Agda.Builtin.Maybe.html#135" class="Datatype">Maybe</a> <a id="1424" href="Data.Maybe.Base.html#1402" class="Bound">A</a> <a id="1426" class="Symbol">→</a> <a id="1428" href="Agda.Primitive.html#388" class="Primitive">Set</a> <a id="1432" href="Data.Maybe.Base.html#719" class="Generalizable">b</a><a id="1433" class="Symbol">}</a> <a id="1435" class="Symbol">→</a>
|
||
<a id="1445" class="Symbol">((</a><a id="1447" href="Data.Maybe.Base.html#1447" class="Bound">x</a> <a id="1449" class="Symbol">:</a> <a id="1451" href="Data.Maybe.Base.html#1402" class="Bound">A</a><a id="1452" class="Symbol">)</a> <a id="1454" class="Symbol">→</a> <a id="1456" href="Data.Maybe.Base.html#1414" class="Bound">B</a> <a id="1458" class="Symbol">(</a><a id="1459" href="Agda.Builtin.Maybe.html#173" class="InductiveConstructor">just</a> <a id="1464" href="Data.Maybe.Base.html#1447" class="Bound">x</a><a id="1465" class="Symbol">))</a> <a id="1468" class="Symbol">→</a> <a id="1470" href="Data.Maybe.Base.html#1414" class="Bound">B</a> <a id="1472" href="Agda.Builtin.Maybe.html#194" class="InductiveConstructor">nothing</a> <a id="1480" class="Symbol">→</a> <a id="1482" class="Symbol">(</a><a id="1483" href="Data.Maybe.Base.html#1483" class="Bound">x</a> <a id="1485" class="Symbol">:</a> <a id="1487" href="Agda.Builtin.Maybe.html#135" class="Datatype">Maybe</a> <a id="1493" href="Data.Maybe.Base.html#1402" class="Bound">A</a><a id="1494" class="Symbol">)</a> <a id="1496" class="Symbol">→</a> <a id="1498" href="Data.Maybe.Base.html#1414" class="Bound">B</a> <a id="1500" href="Data.Maybe.Base.html#1483" class="Bound">x</a>
|
||
<a id="1502" href="Data.Maybe.Base.html#1391" class="Function">maybe</a> <a id="1508" href="Data.Maybe.Base.html#1508" class="Bound">j</a> <a id="1510" href="Data.Maybe.Base.html#1510" class="Bound">n</a> <a id="1512" class="Symbol">(</a><a id="1513" href="Agda.Builtin.Maybe.html#173" class="InductiveConstructor">just</a> <a id="1518" href="Data.Maybe.Base.html#1518" class="Bound">x</a><a id="1519" class="Symbol">)</a> <a id="1521" class="Symbol">=</a> <a id="1523" href="Data.Maybe.Base.html#1508" class="Bound">j</a> <a id="1525" href="Data.Maybe.Base.html#1518" class="Bound">x</a>
|
||
<a id="1527" href="Data.Maybe.Base.html#1391" class="Function">maybe</a> <a id="1533" href="Data.Maybe.Base.html#1533" class="Bound">j</a> <a id="1535" href="Data.Maybe.Base.html#1535" class="Bound">n</a> <a id="1537" href="Agda.Builtin.Maybe.html#194" class="InductiveConstructor">nothing</a> <a id="1546" class="Symbol">=</a> <a id="1548" href="Data.Maybe.Base.html#1535" class="Bound">n</a>
|
||
|
||
<a id="1551" class="Comment">-- A non-dependent eliminator.</a>
|
||
|
||
<a id="maybe′"></a><a id="1583" href="Data.Maybe.Base.html#1583" class="Function">maybe′</a> <a id="1590" class="Symbol">:</a> <a id="1592" class="Symbol">(</a><a id="1593" href="Data.Maybe.Base.html#735" class="Generalizable">A</a> <a id="1595" class="Symbol">→</a> <a id="1597" href="Data.Maybe.Base.html#749" class="Generalizable">B</a><a id="1598" class="Symbol">)</a> <a id="1600" class="Symbol">→</a> <a id="1602" href="Data.Maybe.Base.html#749" class="Generalizable">B</a> <a id="1604" class="Symbol">→</a> <a id="1606" href="Agda.Builtin.Maybe.html#135" class="Datatype">Maybe</a> <a id="1612" href="Data.Maybe.Base.html#735" class="Generalizable">A</a> <a id="1614" class="Symbol">→</a> <a id="1616" href="Data.Maybe.Base.html#749" class="Generalizable">B</a>
|
||
<a id="1618" href="Data.Maybe.Base.html#1583" class="Function">maybe′</a> <a id="1625" class="Symbol">=</a> <a id="1627" href="Data.Maybe.Base.html#1391" class="Function">maybe</a>
|
||
|
||
<a id="1634" class="Comment">-- A defaulting mechanism</a>
|
||
|
||
<a id="fromMaybe"></a><a id="1661" href="Data.Maybe.Base.html#1661" class="Function">fromMaybe</a> <a id="1671" class="Symbol">:</a> <a id="1673" href="Data.Maybe.Base.html#735" class="Generalizable">A</a> <a id="1675" class="Symbol">→</a> <a id="1677" href="Agda.Builtin.Maybe.html#135" class="Datatype">Maybe</a> <a id="1683" href="Data.Maybe.Base.html#735" class="Generalizable">A</a> <a id="1685" class="Symbol">→</a> <a id="1687" href="Data.Maybe.Base.html#735" class="Generalizable">A</a>
|
||
<a id="1689" href="Data.Maybe.Base.html#1661" class="Function">fromMaybe</a> <a id="1699" class="Symbol">=</a> <a id="1701" href="Data.Maybe.Base.html#1583" class="Function">maybe′</a> <a id="1708" href="Function.Base.html#704" class="Function">id</a>
|
||
|
||
<a id="1712" class="Comment">-- A safe variant of "fromJust". If the value is nothing, then the</a>
|
||
<a id="1779" class="Comment">-- return type is the unit type.</a>
|
||
|
||
<a id="1813" class="Keyword">module</a> <a id="1820" href="Data.Maybe.Base.html#1820" class="Module">_</a> <a id="1822" class="Symbol">{</a><a id="1823" href="Data.Maybe.Base.html#1823" class="Bound">a</a><a id="1824" class="Symbol">}</a> <a id="1826" class="Symbol">{</a><a id="1827" href="Data.Maybe.Base.html#1827" class="Bound">A</a> <a id="1829" class="Symbol">:</a> <a id="1831" href="Agda.Primitive.html#388" class="Primitive">Set</a> <a id="1835" href="Data.Maybe.Base.html#1823" class="Bound">a</a><a id="1836" class="Symbol">}</a> <a id="1838" class="Keyword">where</a>
|
||
|
||
<a id="1847" href="Data.Maybe.Base.html#1847" class="Function">From-just</a> <a id="1857" class="Symbol">:</a> <a id="1859" href="Agda.Builtin.Maybe.html#135" class="Datatype">Maybe</a> <a id="1865" href="Data.Maybe.Base.html#1827" class="Bound">A</a> <a id="1867" class="Symbol">→</a> <a id="1869" href="Agda.Primitive.html#388" class="Primitive">Set</a> <a id="1873" href="Data.Maybe.Base.html#1823" class="Bound">a</a>
|
||
<a id="1877" href="Data.Maybe.Base.html#1847" class="Function">From-just</a> <a id="1887" class="Symbol">(</a><a id="1888" href="Agda.Builtin.Maybe.html#173" class="InductiveConstructor">just</a> <a id="1893" class="Symbol">_)</a> <a id="1896" class="Symbol">=</a> <a id="1898" href="Data.Maybe.Base.html#1827" class="Bound">A</a>
|
||
<a id="1902" href="Data.Maybe.Base.html#1847" class="Function">From-just</a> <a id="1912" href="Agda.Builtin.Maybe.html#194" class="InductiveConstructor">nothing</a> <a id="1921" class="Symbol">=</a> <a id="1923" href="Level.html#409" class="Record">Lift</a> <a id="1928" href="Data.Maybe.Base.html#1823" class="Bound">a</a> <a id="1930" href="Agda.Builtin.Unit.html#175" class="Record">⊤</a>
|
||
|
||
<a id="1935" href="Data.Maybe.Base.html#1935" class="Function">from-just</a> <a id="1945" class="Symbol">:</a> <a id="1947" class="Symbol">(</a><a id="1948" href="Data.Maybe.Base.html#1948" class="Bound">x</a> <a id="1950" class="Symbol">:</a> <a id="1952" href="Agda.Builtin.Maybe.html#135" class="Datatype">Maybe</a> <a id="1958" href="Data.Maybe.Base.html#1827" class="Bound">A</a><a id="1959" class="Symbol">)</a> <a id="1961" class="Symbol">→</a> <a id="1963" href="Data.Maybe.Base.html#1847" class="Function">From-just</a> <a id="1973" href="Data.Maybe.Base.html#1948" class="Bound">x</a>
|
||
<a id="1977" href="Data.Maybe.Base.html#1935" class="Function">from-just</a> <a id="1987" class="Symbol">(</a><a id="1988" href="Agda.Builtin.Maybe.html#173" class="InductiveConstructor">just</a> <a id="1993" href="Data.Maybe.Base.html#1993" class="Bound">x</a><a id="1994" class="Symbol">)</a> <a id="1996" class="Symbol">=</a> <a id="1998" href="Data.Maybe.Base.html#1993" class="Bound">x</a>
|
||
<a id="2002" href="Data.Maybe.Base.html#1935" class="Function">from-just</a> <a id="2012" href="Agda.Builtin.Maybe.html#194" class="InductiveConstructor">nothing</a> <a id="2021" class="Symbol">=</a> <a id="2023" class="Symbol">_</a>
|
||
|
||
<a id="2026" class="Comment">-- Functoriality: map</a>
|
||
|
||
<a id="map"></a><a id="2049" href="Data.Maybe.Base.html#2049" class="Function">map</a> <a id="2053" class="Symbol">:</a> <a id="2055" class="Symbol">(</a><a id="2056" href="Data.Maybe.Base.html#735" class="Generalizable">A</a> <a id="2058" class="Symbol">→</a> <a id="2060" href="Data.Maybe.Base.html#749" class="Generalizable">B</a><a id="2061" class="Symbol">)</a> <a id="2063" class="Symbol">→</a> <a id="2065" href="Agda.Builtin.Maybe.html#135" class="Datatype">Maybe</a> <a id="2071" href="Data.Maybe.Base.html#735" class="Generalizable">A</a> <a id="2073" class="Symbol">→</a> <a id="2075" href="Agda.Builtin.Maybe.html#135" class="Datatype">Maybe</a> <a id="2081" href="Data.Maybe.Base.html#749" class="Generalizable">B</a>
|
||
<a id="2083" href="Data.Maybe.Base.html#2049" class="Function">map</a> <a id="2087" href="Data.Maybe.Base.html#2087" class="Bound">f</a> <a id="2089" class="Symbol">=</a> <a id="2091" href="Data.Maybe.Base.html#1391" class="Function">maybe</a> <a id="2097" class="Symbol">(</a><a id="2098" href="Agda.Builtin.Maybe.html#173" class="InductiveConstructor">just</a> <a id="2103" href="Function.Base.html#1115" class="Function Operator">∘</a> <a id="2105" href="Data.Maybe.Base.html#2087" class="Bound">f</a><a id="2106" class="Symbol">)</a> <a id="2108" href="Agda.Builtin.Maybe.html#194" class="InductiveConstructor">nothing</a>
|
||
|
||
<a id="2117" class="Comment">-- Applicative: ap</a>
|
||
|
||
<a id="ap"></a><a id="2137" href="Data.Maybe.Base.html#2137" class="Function">ap</a> <a id="2140" class="Symbol">:</a> <a id="2142" href="Agda.Builtin.Maybe.html#135" class="Datatype">Maybe</a> <a id="2148" class="Symbol">(</a><a id="2149" href="Data.Maybe.Base.html#735" class="Generalizable">A</a> <a id="2151" class="Symbol">→</a> <a id="2153" href="Data.Maybe.Base.html#749" class="Generalizable">B</a><a id="2154" class="Symbol">)</a> <a id="2156" class="Symbol">→</a> <a id="2158" href="Agda.Builtin.Maybe.html#135" class="Datatype">Maybe</a> <a id="2164" href="Data.Maybe.Base.html#735" class="Generalizable">A</a> <a id="2166" class="Symbol">→</a> <a id="2168" href="Agda.Builtin.Maybe.html#135" class="Datatype">Maybe</a> <a id="2174" href="Data.Maybe.Base.html#749" class="Generalizable">B</a>
|
||
<a id="2176" href="Data.Maybe.Base.html#2137" class="Function">ap</a> <a id="2179" href="Agda.Builtin.Maybe.html#194" class="InductiveConstructor">nothing</a> <a id="2188" class="Symbol">=</a> <a id="2190" href="Function.Base.html#725" class="Function">const</a> <a id="2196" href="Agda.Builtin.Maybe.html#194" class="InductiveConstructor">nothing</a>
|
||
<a id="2204" href="Data.Maybe.Base.html#2137" class="Function">ap</a> <a id="2207" class="Symbol">(</a><a id="2208" href="Agda.Builtin.Maybe.html#173" class="InductiveConstructor">just</a> <a id="2213" href="Data.Maybe.Base.html#2213" class="Bound">f</a><a id="2214" class="Symbol">)</a> <a id="2216" class="Symbol">=</a> <a id="2218" href="Data.Maybe.Base.html#2049" class="Function">map</a> <a id="2222" href="Data.Maybe.Base.html#2213" class="Bound">f</a>
|
||
|
||
<a id="2225" class="Comment">-- Monad: bind</a>
|
||
|
||
<a id="2241" class="Keyword">infixl</a> <a id="2248" class="Number">1</a> <a id="2250" href="Data.Maybe.Base.html#2256" class="Function Operator">_>>=_</a>
|
||
<a id="_>>=_"></a><a id="2256" href="Data.Maybe.Base.html#2256" class="Function Operator">_>>=_</a> <a id="2262" class="Symbol">:</a> <a id="2264" href="Agda.Builtin.Maybe.html#135" class="Datatype">Maybe</a> <a id="2270" href="Data.Maybe.Base.html#735" class="Generalizable">A</a> <a id="2272" class="Symbol">→</a> <a id="2274" class="Symbol">(</a><a id="2275" href="Data.Maybe.Base.html#735" class="Generalizable">A</a> <a id="2277" class="Symbol">→</a> <a id="2279" href="Agda.Builtin.Maybe.html#135" class="Datatype">Maybe</a> <a id="2285" href="Data.Maybe.Base.html#749" class="Generalizable">B</a><a id="2286" class="Symbol">)</a> <a id="2288" class="Symbol">→</a> <a id="2290" href="Agda.Builtin.Maybe.html#135" class="Datatype">Maybe</a> <a id="2296" href="Data.Maybe.Base.html#749" class="Generalizable">B</a>
|
||
<a id="2298" href="Agda.Builtin.Maybe.html#194" class="InductiveConstructor">nothing</a> <a id="2306" href="Data.Maybe.Base.html#2256" class="Function Operator">>>=</a> <a id="2310" href="Data.Maybe.Base.html#2310" class="Bound">f</a> <a id="2312" class="Symbol">=</a> <a id="2314" href="Agda.Builtin.Maybe.html#194" class="InductiveConstructor">nothing</a>
|
||
<a id="2322" href="Agda.Builtin.Maybe.html#173" class="InductiveConstructor">just</a> <a id="2327" href="Data.Maybe.Base.html#2327" class="Bound">a</a> <a id="2330" href="Data.Maybe.Base.html#2256" class="Function Operator">>>=</a> <a id="2334" href="Data.Maybe.Base.html#2334" class="Bound">f</a> <a id="2336" class="Symbol">=</a> <a id="2338" href="Data.Maybe.Base.html#2334" class="Bound">f</a> <a id="2340" href="Data.Maybe.Base.html#2327" class="Bound">a</a>
|
||
|
||
<a id="2343" class="Comment">-- Alternative: <∣></a>
|
||
|
||
<a id="2364" class="Keyword">infixr</a> <a id="2371" class="Number">6</a> <a id="2373" href="Data.Maybe.Base.html#2379" class="Function Operator">_<∣>_</a>
|
||
<a id="_<∣>_"></a><a id="2379" href="Data.Maybe.Base.html#2379" class="Function Operator">_<∣>_</a> <a id="2385" class="Symbol">:</a> <a id="2387" href="Agda.Builtin.Maybe.html#135" class="Datatype">Maybe</a> <a id="2393" href="Data.Maybe.Base.html#735" class="Generalizable">A</a> <a id="2395" class="Symbol">→</a> <a id="2397" href="Agda.Builtin.Maybe.html#135" class="Datatype">Maybe</a> <a id="2403" href="Data.Maybe.Base.html#735" class="Generalizable">A</a> <a id="2405" class="Symbol">→</a> <a id="2407" href="Agda.Builtin.Maybe.html#135" class="Datatype">Maybe</a> <a id="2413" href="Data.Maybe.Base.html#735" class="Generalizable">A</a>
|
||
<a id="2415" href="Agda.Builtin.Maybe.html#173" class="InductiveConstructor">just</a> <a id="2420" href="Data.Maybe.Base.html#2420" class="Bound">x</a> <a id="2423" href="Data.Maybe.Base.html#2379" class="Function Operator"><∣></a> <a id="2427" href="Data.Maybe.Base.html#2427" class="Bound">my</a> <a id="2430" class="Symbol">=</a> <a id="2432" href="Agda.Builtin.Maybe.html#173" class="InductiveConstructor">just</a> <a id="2437" href="Data.Maybe.Base.html#2420" class="Bound">x</a>
|
||
<a id="2439" href="Agda.Builtin.Maybe.html#194" class="InductiveConstructor">nothing</a> <a id="2447" href="Data.Maybe.Base.html#2379" class="Function Operator"><∣></a> <a id="2451" href="Data.Maybe.Base.html#2451" class="Bound">my</a> <a id="2454" class="Symbol">=</a> <a id="2456" href="Data.Maybe.Base.html#2451" class="Bound">my</a>
|
||
|
||
<a id="2460" class="Comment">-- Just when the boolean is true</a>
|
||
|
||
<a id="when"></a><a id="2494" href="Data.Maybe.Base.html#2494" class="Function">when</a> <a id="2499" class="Symbol">:</a> <a id="2501" href="Agda.Builtin.Bool.html#173" class="Datatype">Bool</a> <a id="2506" class="Symbol">→</a> <a id="2508" href="Data.Maybe.Base.html#735" class="Generalizable">A</a> <a id="2510" class="Symbol">→</a> <a id="2512" href="Agda.Builtin.Maybe.html#135" class="Datatype">Maybe</a> <a id="2518" href="Data.Maybe.Base.html#735" class="Generalizable">A</a>
|
||
<a id="2520" href="Data.Maybe.Base.html#2494" class="Function">when</a> <a id="2525" href="Data.Maybe.Base.html#2525" class="Bound">b</a> <a id="2527" href="Data.Maybe.Base.html#2527" class="Bound">c</a> <a id="2529" class="Symbol">=</a> <a id="2531" href="Data.Maybe.Base.html#2049" class="Function">map</a> <a id="2535" class="Symbol">(</a><a id="2536" href="Function.Base.html#725" class="Function">const</a> <a id="2542" href="Data.Maybe.Base.html#2527" class="Bound">c</a><a id="2543" class="Symbol">)</a> <a id="2545" class="Symbol">(</a><a id="2546" href="Data.Maybe.Base.html#1025" class="Function">boolToMaybe</a> <a id="2558" href="Data.Maybe.Base.html#2525" class="Bound">b</a><a id="2559" class="Symbol">)</a>
|
||
|
||
<a id="2562" class="Comment">------------------------------------------------------------------------</a>
|
||
<a id="2635" class="Comment">-- Aligning and zipping</a>
|
||
|
||
<a id="alignWith"></a><a id="2660" href="Data.Maybe.Base.html#2660" class="Function">alignWith</a> <a id="2670" class="Symbol">:</a> <a id="2672" class="Symbol">(</a><a id="2673" href="Data.These.Base.html#537" class="Datatype">These</a> <a id="2679" href="Data.Maybe.Base.html#735" class="Generalizable">A</a> <a id="2681" href="Data.Maybe.Base.html#749" class="Generalizable">B</a> <a id="2683" class="Symbol">→</a> <a id="2685" href="Data.Maybe.Base.html#763" class="Generalizable">C</a><a id="2686" class="Symbol">)</a> <a id="2688" class="Symbol">→</a> <a id="2690" href="Agda.Builtin.Maybe.html#135" class="Datatype">Maybe</a> <a id="2696" href="Data.Maybe.Base.html#735" class="Generalizable">A</a> <a id="2698" class="Symbol">→</a> <a id="2700" href="Agda.Builtin.Maybe.html#135" class="Datatype">Maybe</a> <a id="2706" href="Data.Maybe.Base.html#749" class="Generalizable">B</a> <a id="2708" class="Symbol">→</a> <a id="2710" href="Agda.Builtin.Maybe.html#135" class="Datatype">Maybe</a> <a id="2716" href="Data.Maybe.Base.html#763" class="Generalizable">C</a>
|
||
<a id="2718" href="Data.Maybe.Base.html#2660" class="Function">alignWith</a> <a id="2728" href="Data.Maybe.Base.html#2728" class="Bound">f</a> <a id="2730" class="Symbol">(</a><a id="2731" href="Agda.Builtin.Maybe.html#173" class="InductiveConstructor">just</a> <a id="2736" href="Data.Maybe.Base.html#2736" class="Bound">a</a><a id="2737" class="Symbol">)</a> <a id="2739" class="Symbol">(</a><a id="2740" href="Agda.Builtin.Maybe.html#173" class="InductiveConstructor">just</a> <a id="2745" href="Data.Maybe.Base.html#2745" class="Bound">b</a><a id="2746" class="Symbol">)</a> <a id="2748" class="Symbol">=</a> <a id="2750" href="Agda.Builtin.Maybe.html#173" class="InductiveConstructor">just</a> <a id="2755" class="Symbol">(</a><a id="2756" href="Data.Maybe.Base.html#2728" class="Bound">f</a> <a id="2758" class="Symbol">(</a><a id="2759" href="Data.These.Base.html#651" class="InductiveConstructor">these</a> <a id="2765" href="Data.Maybe.Base.html#2736" class="Bound">a</a> <a id="2767" href="Data.Maybe.Base.html#2745" class="Bound">b</a><a id="2768" class="Symbol">))</a>
|
||
<a id="2771" href="Data.Maybe.Base.html#2660" class="Function">alignWith</a> <a id="2781" href="Data.Maybe.Base.html#2781" class="Bound">f</a> <a id="2783" class="Symbol">(</a><a id="2784" href="Agda.Builtin.Maybe.html#173" class="InductiveConstructor">just</a> <a id="2789" href="Data.Maybe.Base.html#2789" class="Bound">a</a><a id="2790" class="Symbol">)</a> <a id="2792" href="Agda.Builtin.Maybe.html#194" class="InductiveConstructor">nothing</a> <a id="2801" class="Symbol">=</a> <a id="2803" href="Agda.Builtin.Maybe.html#173" class="InductiveConstructor">just</a> <a id="2808" class="Symbol">(</a><a id="2809" href="Data.Maybe.Base.html#2781" class="Bound">f</a> <a id="2811" class="Symbol">(</a><a id="2812" href="Data.These.Base.html#595" class="InductiveConstructor">this</a> <a id="2817" href="Data.Maybe.Base.html#2789" class="Bound">a</a><a id="2818" class="Symbol">))</a>
|
||
<a id="2821" href="Data.Maybe.Base.html#2660" class="Function">alignWith</a> <a id="2831" href="Data.Maybe.Base.html#2831" class="Bound">f</a> <a id="2833" href="Agda.Builtin.Maybe.html#194" class="InductiveConstructor">nothing</a> <a id="2842" class="Symbol">(</a><a id="2843" href="Agda.Builtin.Maybe.html#173" class="InductiveConstructor">just</a> <a id="2848" href="Data.Maybe.Base.html#2848" class="Bound">b</a><a id="2849" class="Symbol">)</a> <a id="2851" class="Symbol">=</a> <a id="2853" href="Agda.Builtin.Maybe.html#173" class="InductiveConstructor">just</a> <a id="2858" class="Symbol">(</a><a id="2859" href="Data.Maybe.Base.html#2831" class="Bound">f</a> <a id="2861" class="Symbol">(</a><a id="2862" href="Data.These.Base.html#623" class="InductiveConstructor">that</a> <a id="2867" href="Data.Maybe.Base.html#2848" class="Bound">b</a><a id="2868" class="Symbol">))</a>
|
||
<a id="2871" href="Data.Maybe.Base.html#2660" class="Function">alignWith</a> <a id="2881" href="Data.Maybe.Base.html#2881" class="Bound">f</a> <a id="2883" href="Agda.Builtin.Maybe.html#194" class="InductiveConstructor">nothing</a> <a id="2892" href="Agda.Builtin.Maybe.html#194" class="InductiveConstructor">nothing</a> <a id="2901" class="Symbol">=</a> <a id="2903" href="Agda.Builtin.Maybe.html#194" class="InductiveConstructor">nothing</a>
|
||
|
||
<a id="zipWith"></a><a id="2912" href="Data.Maybe.Base.html#2912" class="Function">zipWith</a> <a id="2920" class="Symbol">:</a> <a id="2922" class="Symbol">(</a><a id="2923" href="Data.Maybe.Base.html#735" class="Generalizable">A</a> <a id="2925" class="Symbol">→</a> <a id="2927" href="Data.Maybe.Base.html#749" class="Generalizable">B</a> <a id="2929" class="Symbol">→</a> <a id="2931" href="Data.Maybe.Base.html#763" class="Generalizable">C</a><a id="2932" class="Symbol">)</a> <a id="2934" class="Symbol">→</a> <a id="2936" href="Agda.Builtin.Maybe.html#135" class="Datatype">Maybe</a> <a id="2942" href="Data.Maybe.Base.html#735" class="Generalizable">A</a> <a id="2944" class="Symbol">→</a> <a id="2946" href="Agda.Builtin.Maybe.html#135" class="Datatype">Maybe</a> <a id="2952" href="Data.Maybe.Base.html#749" class="Generalizable">B</a> <a id="2954" class="Symbol">→</a> <a id="2956" href="Agda.Builtin.Maybe.html#135" class="Datatype">Maybe</a> <a id="2962" href="Data.Maybe.Base.html#763" class="Generalizable">C</a>
|
||
<a id="2964" href="Data.Maybe.Base.html#2912" class="Function">zipWith</a> <a id="2972" href="Data.Maybe.Base.html#2972" class="Bound">f</a> <a id="2974" class="Symbol">(</a><a id="2975" href="Agda.Builtin.Maybe.html#173" class="InductiveConstructor">just</a> <a id="2980" href="Data.Maybe.Base.html#2980" class="Bound">a</a><a id="2981" class="Symbol">)</a> <a id="2983" class="Symbol">(</a><a id="2984" href="Agda.Builtin.Maybe.html#173" class="InductiveConstructor">just</a> <a id="2989" href="Data.Maybe.Base.html#2989" class="Bound">b</a><a id="2990" class="Symbol">)</a> <a id="2992" class="Symbol">=</a> <a id="2994" href="Agda.Builtin.Maybe.html#173" class="InductiveConstructor">just</a> <a id="2999" class="Symbol">(</a><a id="3000" href="Data.Maybe.Base.html#2972" class="Bound">f</a> <a id="3002" href="Data.Maybe.Base.html#2980" class="Bound">a</a> <a id="3004" href="Data.Maybe.Base.html#2989" class="Bound">b</a><a id="3005" class="Symbol">)</a>
|
||
<a id="3007" href="Data.Maybe.Base.html#2912" class="CatchallClause Function">zipWith</a><a id="3014" class="CatchallClause"> </a><a id="3015" class="CatchallClause Symbol">_</a><a id="3016" class="CatchallClause"> </a><a id="3017" class="CatchallClause Symbol">_</a><a id="3018" class="CatchallClause"> </a><a id="3026" class="CatchallClause Symbol">_</a> <a id="3035" class="Symbol">=</a> <a id="3037" href="Agda.Builtin.Maybe.html#194" class="InductiveConstructor">nothing</a>
|
||
|
||
<a id="align"></a><a id="3046" href="Data.Maybe.Base.html#3046" class="Function">align</a> <a id="3052" class="Symbol">:</a> <a id="3054" href="Agda.Builtin.Maybe.html#135" class="Datatype">Maybe</a> <a id="3060" href="Data.Maybe.Base.html#735" class="Generalizable">A</a> <a id="3062" class="Symbol">→</a> <a id="3064" href="Agda.Builtin.Maybe.html#135" class="Datatype">Maybe</a> <a id="3070" href="Data.Maybe.Base.html#749" class="Generalizable">B</a> <a id="3072" class="Symbol">→</a> <a id="3074" href="Agda.Builtin.Maybe.html#135" class="Datatype">Maybe</a> <a id="3080" class="Symbol">(</a><a id="3081" href="Data.These.Base.html#537" class="Datatype">These</a> <a id="3087" href="Data.Maybe.Base.html#735" class="Generalizable">A</a> <a id="3089" href="Data.Maybe.Base.html#749" class="Generalizable">B</a><a id="3090" class="Symbol">)</a>
|
||
<a id="3092" href="Data.Maybe.Base.html#3046" class="Function">align</a> <a id="3098" class="Symbol">=</a> <a id="3100" href="Data.Maybe.Base.html#2660" class="Function">alignWith</a> <a id="3110" href="Function.Base.html#704" class="Function">id</a>
|
||
|
||
<a id="zip"></a><a id="3114" href="Data.Maybe.Base.html#3114" class="Function">zip</a> <a id="3118" class="Symbol">:</a> <a id="3120" href="Agda.Builtin.Maybe.html#135" class="Datatype">Maybe</a> <a id="3126" href="Data.Maybe.Base.html#735" class="Generalizable">A</a> <a id="3128" class="Symbol">→</a> <a id="3130" href="Agda.Builtin.Maybe.html#135" class="Datatype">Maybe</a> <a id="3136" href="Data.Maybe.Base.html#749" class="Generalizable">B</a> <a id="3138" class="Symbol">→</a> <a id="3140" href="Agda.Builtin.Maybe.html#135" class="Datatype">Maybe</a> <a id="3146" class="Symbol">(</a><a id="3147" href="Data.Maybe.Base.html#735" class="Generalizable">A</a> <a id="3149" href="Data.Product.Base.html#1618" class="Function Operator">×</a> <a id="3151" href="Data.Maybe.Base.html#749" class="Generalizable">B</a><a id="3152" class="Symbol">)</a>
|
||
<a id="3154" href="Data.Maybe.Base.html#3114" class="Function">zip</a> <a id="3158" class="Symbol">=</a> <a id="3160" href="Data.Maybe.Base.html#2912" class="Function">zipWith</a> <a id="3168" href="Agda.Builtin.Sigma.html#235" class="InductiveConstructor Operator">_,_</a>
|
||
|
||
<a id="3173" class="Comment">------------------------------------------------------------------------</a>
|
||
<a id="3246" class="Comment">-- Injections.</a>
|
||
|
||
<a id="thisM"></a><a id="3262" href="Data.Maybe.Base.html#3262" class="Function">thisM</a> <a id="3268" class="Symbol">:</a> <a id="3270" href="Data.Maybe.Base.html#735" class="Generalizable">A</a> <a id="3272" class="Symbol">→</a> <a id="3274" href="Agda.Builtin.Maybe.html#135" class="Datatype">Maybe</a> <a id="3280" href="Data.Maybe.Base.html#749" class="Generalizable">B</a> <a id="3282" class="Symbol">→</a> <a id="3284" href="Data.These.Base.html#537" class="Datatype">These</a> <a id="3290" href="Data.Maybe.Base.html#735" class="Generalizable">A</a> <a id="3292" href="Data.Maybe.Base.html#749" class="Generalizable">B</a>
|
||
<a id="3294" href="Data.Maybe.Base.html#3262" class="Function">thisM</a> <a id="3300" href="Data.Maybe.Base.html#3300" class="Bound">a</a> <a id="3302" class="Symbol">=</a> <a id="3304" href="Data.Maybe.Base.html#1583" class="Function">maybe′</a> <a id="3311" class="Symbol">(</a><a id="3312" href="Data.These.Base.html#651" class="InductiveConstructor">these</a> <a id="3318" href="Data.Maybe.Base.html#3300" class="Bound">a</a><a id="3319" class="Symbol">)</a> <a id="3321" class="Symbol">(</a><a id="3322" href="Data.These.Base.html#595" class="InductiveConstructor">this</a> <a id="3327" href="Data.Maybe.Base.html#3300" class="Bound">a</a><a id="3328" class="Symbol">)</a>
|
||
|
||
<a id="thatM"></a><a id="3331" href="Data.Maybe.Base.html#3331" class="Function">thatM</a> <a id="3337" class="Symbol">:</a> <a id="3339" href="Agda.Builtin.Maybe.html#135" class="Datatype">Maybe</a> <a id="3345" href="Data.Maybe.Base.html#735" class="Generalizable">A</a> <a id="3347" class="Symbol">→</a> <a id="3349" href="Data.Maybe.Base.html#749" class="Generalizable">B</a> <a id="3351" class="Symbol">→</a> <a id="3353" href="Data.These.Base.html#537" class="Datatype">These</a> <a id="3359" href="Data.Maybe.Base.html#735" class="Generalizable">A</a> <a id="3361" href="Data.Maybe.Base.html#749" class="Generalizable">B</a>
|
||
<a id="3363" href="Data.Maybe.Base.html#3331" class="Function">thatM</a> <a id="3369" class="Symbol">=</a> <a id="3371" href="Data.Maybe.Base.html#1583" class="Function">maybe′</a> <a id="3378" href="Data.These.Base.html#651" class="InductiveConstructor">these</a> <a id="3384" href="Data.These.Base.html#623" class="InductiveConstructor">that</a>
|
||
</pre></body></html> |