title: Type classes, instances and wrappers
body: <p>can somebody explain to me why this(version 1) compiles while the version below(version 2) does not.</p>
  
  <pre><code>-- version 1 (compiles)
  module Chapter2 where
  
  import Debug.Trace
  
  data Wrapper a = Wrapper a
  instance showWrapper :: (Show a) =&gt; Show (Wrapper a) where
      show (Wrapper w) = "Wrapper ( " ++ (show w) ++ " )"
  
  foo :: Number -&gt; Number -&gt; Number -&gt; Number
  foo a b c = a + b + c
  foo1 = foo 2
  foo2 = foo 1 2
  
  class ExecFn a where
      exec :: a -&gt; Number
  
  instance execFn1 :: ExecFn (Number -&gt; Number -&gt; Number) where
      exec a = 99
  
  main = do
      let x = exec foo1
      trace "Hello"
  </code></pre>
  
  <p>This does not compile</p>
  
  <pre><code>-- Version 2 (does not compile)
  module Chapter2 where
  
  import Debug.Trace
  
  data Wrapper a = Wrapper a
  instance showWrapper :: (Show a) =&gt; Show (Wrapper a) where
      show (Wrapper w) = "Wrapper ( " ++ (show w) ++ " )"
  
  foo :: Number -&gt; Number -&gt; Number -&gt; Number
  foo a b c = a + b + c
  foo1 = foo 2
  foo2 = foo 1 2
  
  class ExecFn a b where
      exec :: a -&gt; Wrapper b
  
  instance execFn1 :: ExecFn (Number -&gt; Number -&gt; Number) Number where
      exec a = Wrapper 99
  
  main = do
      let x = exec foo1
      trace "Hello"    
  </code></pre>
  
  <p>and gives me this error</p>
  
  <pre><code>Error at src/Chapter2.purs line 3, column 1 - line 5, column 1:
    No instance found for Chapter2.ExecFn (Prim.Number -&gt; Prim.Number -&gt; Prim.Number) u8735
  </code></pre>
  
  <p>So how can I make a version similar to my version 2 so that I can put my result into a wrapper?</p>