codesnippets:parametrictypeforanintermediatevaluewhencombiningfunctions

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
codesnippets:parametrictypeforanintermediatevaluewhencombiningfunctions [2021/04/24 22:35] f2b216codesnippets:parametrictypeforanintermediatevaluewhencombiningfunctions [2025/10/08 00:48] (current) – external edit 127.0.0.1
Line 1: Line 1:
 ====== Parametric type for an intermediate value when combining functions ====== ====== Parametric type for an intermediate value when combining functions ======
-~~DISCUSSION~~ 
  
   * example with the folling problem(s):   * example with the folling problem(s):
Line 32: Line 31:
     render (Contains (MyData n)) = Oct.toOctets n     render (Contains (MyData n)) = Oct.toOctets n
     render (Error _) = []     render (Error _) = []
 +</code>
 +    * compiles, with error:<code>
 +app\Main.hs:19:5: error:
 +    * Could not deduce (Builder g0)
 +      from the context: Builder g
 +        bound by the type signature for:
 +                   buildNRender :: forall g. Builder g => String -> [W.Word8]
 +        at app\Main.hs:19:5-39
 +      The type variable `g0' is ambiguous
 +    * In the ambiguity check for `buildNRender'
 +      To defer the ambiguity check to use sites, enable AllowAmbiguousTypes
 +      When checking the class method:
 +        buildNRender :: forall g. Builder g => String -> [W.Word8]
 +      In the class declaration for `Builder'
 +   |
 +19 |     buildNRender :: String -> [W.Word8]
 +       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 </code> </code>
   * example that solves the problem with extensions   * example that solves the problem with extensions
Line 137: Line 153:
 </code> </code>
  
 +
 +===== ✎ =====
 +~~DISCUSSION~~
codesnippets/parametrictypeforanintermediatevaluewhencombiningfunctions.1619296546.txt.gz · Last modified: (external edit)

Except where otherwise noted, content on this wiki is licensed under the following license: CC0 1.0 Universal
CC0 1.0 Universal Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki