1
0
mirror of https://github.com/ubf/ubf.git synced 2026-04-23 05:05:43 +00:00
Files
ubf/edoc/contracts.html

88 lines
4.4 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Module contracts</title>
<link rel="stylesheet" type="text/css" href="stylesheet.css" title="EDoc">
</head>
<body bgcolor="white">
<div class="navbar"><a name="#navbar_top"></a><table width="100%" border="0" cellspacing="0" cellpadding="2" summary="navigation bar"><tr><td><a href="overview-summary.html" target="overviewFrame">Overview</a></td><td><a href="http://www.erlang.org/"><img src="erlang.png" align="right" border="0" alt="erlang logo"></a></td></tr></table></div>
<hr>
<h1>Module contracts</h1>
<ul class="index"><li><a href="#description">Description</a></li><li><a href="#index">Function Index</a></li><li><a href="#functions">Function Details</a></li></ul>Contract implementation: compare a term against a contract.
<h2><a name="description">Description</a></h2><p>Contract implementation: compare a term against a contract.</p>
See the function checkType/3 for assistance on checking if a term
does/does not break a contract.
<h2><a name="index">Function Index</a></h2>
<table width="100%" border="1" cellspacing="0" cellpadding="2" summary="function index"><tr><td valign="top"><a href="#checkEventIn-3">checkEventIn/3</a></td><td></td></tr>
<tr><td valign="top"><a href="#checkEventOut-3">checkEventOut/3</a></td><td></td></tr>
<tr><td valign="top"><a href="#checkRPCIn-3">checkRPCIn/3</a></td><td></td></tr>
<tr><td valign="top"><a href="#checkRPCOut-4">checkRPCOut/4</a></td><td></td></tr>
<tr><td valign="top"><a href="#checkType-3">checkType/3</a></td><td>Given a contract type name, a term to check against that
contract type, and a contract module name, verify the term against
that contract's type.</td></tr>
<tr><td valign="top"><a href="#isType-3">isType/3</a></td><td></td></tr>
<tr><td valign="top"><a href="#isTypeAttr-2">isTypeAttr/2</a></td><td></td></tr>
</table>
<h2><a name="functions">Function Details</a></h2>
<h3 class="function"><a name="checkEventIn-3">checkEventIn/3</a></h3>
<div class="spec">
<p><tt>checkEventIn(Msg, ThisState, Mod) -&gt; any()</tt></p>
</div>
<h3 class="function"><a name="checkEventOut-3">checkEventOut/3</a></h3>
<div class="spec">
<p><tt>checkEventOut(Msg, ThisState, Mod) -&gt; any()</tt></p>
</div>
<h3 class="function"><a name="checkRPCIn-3">checkRPCIn/3</a></h3>
<div class="spec">
<p><tt>checkRPCIn(Msg, State, Mod) -&gt; any()</tt></p>
</div>
<h3 class="function"><a name="checkRPCOut-4">checkRPCOut/4</a></h3>
<div class="spec">
<p><tt>checkRPCOut(MsgOut, StateOut, FSM2, Mod) -&gt; any()</tt></p>
</div>
<h3 class="function"><a name="checkType-3">checkType/3</a></h3>
<div class="spec">
<p><tt>checkType(HumanType::<a href="#type-contract_type_name_atom">contract_type_name_atom()</a>, Term::term(), Mod::<a href="#type-contract_module_name_atom">contract_module_name_atom()</a>) -&gt; yup | <a href="#type-error_hints_term_only_human_readable_sorry">error_hints_term_only_human_readable_sorry()</a></tt></p>
</div><p><p>Given a contract type name, a term to check against that
contract type, and a contract module name, verify the term against
that contract's type.</p>
Example usage from the irc_plugin.con contract:
<ul>
<li> contracts:checkType(ok, ok, irc_plugin). </li>
<li> contracts:checkType(bool, true, irc_plugin). </li>
<li> contracts:checkType(nick, {'#S', "foo"}, irc_plugin). </li>
<li> contracts:checkType(joinEvent, {joins, {'#S', "nck"}, {'#S', "grp"}}, irc_plugin). </li>
<li> contracts:checkType(joinEvent, {joins, {'#S', "nck"}, {'#S', bad_atom}}, irc_plugin). </li>
</ul>
NOTE: This is a brute-force function, but it works, mostly. Don't
try to have a computer parse the output in error cases: the failure
output is meant only for human eyes.</p>
<h3 class="function"><a name="isType-3">isType/3</a></h3>
<div class="spec">
<p><tt>isType(Type, X, Mod) -&gt; any()</tt></p>
</div>
<h3 class="function"><a name="isTypeAttr-2">isTypeAttr/2</a></h3>
<div class="spec">
<p><tt>isTypeAttr(X1, X2) -&gt; any()</tt></p>
</div>
<hr>
<div class="navbar"><a name="#navbar_bottom"></a><table width="100%" border="0" cellspacing="0" cellpadding="2" summary="navigation bar"><tr><td><a href="overview-summary.html" target="overviewFrame">Overview</a></td><td><a href="http://www.erlang.org/"><img src="erlang.png" align="right" border="0" alt="erlang logo"></a></td></tr></table></div>
<p><i>Generated EDoc, $Id$</i></p>
</body>
</html>