# Source: https://www.roc-lang.org/abilities#inspect-ability

# Abilities | Roc

# Encode.roc
# Encode.roc
Encoding implements to_encoder : val -> Encoder where
a implements Encoding
Encoder implements ToEncoder
...
</samp></pre> <p><strong>Implementing <code>to_encoder</code></strong> is as simple as adding a function with the required type signature to a type implementing <code>Encoding</code>.</p> <p><strong>Example</strong> of a type implementing <code>ToEncoder</code> and a concrete type implementing <code>Encoding</code>.</p> <pre><samp><span class="comment"># Str.roc</span><span class="upperident"> Str</span><span class="lowerident"> implements</span><span class="kw"> to</span><span class="lowerident">_</span><span class="lowerident">encoder</span><span class="kw"> :</span><span class="lowerident"> Str</span><span class="kw"> -&gt;</span><span class="upperident"> Encoder</span><span class="lowerident"> where</span><span class="lowerident"> a</span><span class="lowerident"> implements</span><span class="upperident"> Str</span><span class="delimeter">,</span><span class="lowerident"> Encoder</span><span class="lowerident"> implements</span><span class="upperident"> ToEncoder</span></samp></pre> <pre><samp><span class="comment"># U8.roc</span><span class="upperident"> U8</span><span class="lowerident"> implements</span><span class="kw"> to</span><span class="lowerident">_</span><span class="lowerident">encoder</span><span class="kw"> :</span><span class="lowerident"> U8</span><span class="kw"> -&gt;</span><span class="upperident"> Encoder</span><span class="lowerident"> where</span><span class="lowerident"> a</span><span class="lowerident"> implements</span><span class="upperident"> U8</span><span class="delimeter">,</span><span class="lowerident"> Encoder</span><span class="lowerident"> implements</span><span class="upperident"> ToEncoder</span></samp></pre> <pre><samp><span class="comment"># Str.roc</span><span class="upperident"> Str</span><span class="lowerident"> implements</span><span class="kw"> to</span><span class="lowerident">_</span><span class="lowerident">encoder</span><span class="kw"> :</span><span class="lowerident"> Str</span><span class="kw"> -&gt;</span><span class="upperident"> Encoder</span><span class="lowerident"> where</span><span class="lowerident"> a</span><span class="lowerident"> implements</span><span class="upperident"> Str</span><span class="delimeter">,</span><span class="lowerident"> Encoder</span><span class="lowerident"> implements</span><span class="upperident"> ToEncoder</span><span class="kw"> |</span><span class="lowerident"> val</span><span class="kw"> -&gt;</span><span class="upperident"> Encoder</span><span class="lowerident"> where</span><span class="lowerident"> a</span><span class="lowerident"> implements</span><span class="upperident"> Str</span><span class="delimeter">,</span><span class="lowerident"> Encoder</span><span class="lowerident"> implements</span><span class="upperident"> ToEncoder</span></samp></pre> <pre><samp><span class="comment"># U8.roc</span><span class="upperident"> U8</span><span class="lowerident"> implements</span><span class="kw"> to</span><span class="lower