title: Extending GADTs examples - could not deduce
body: <p>I'm trying to extend the classic GADTs example around eval-ing a <code>Value</code>, but I'm hitting something I don't fully understand.</p>
  <pre class="lang-hs prettyprint-override"><code>data Command a where
      Base64_     :: Command a
      Take_       :: Int -&gt; Command a
  
  -- eval only works with this definition
  -- with this uncommented, cmd breaks with:
  --
  -- Could not deduce: v ~ T.Text
  --  from the context: a ~ T.Text
  --    bound by a pattern with constructor:
  --               VString :: T.Text -&gt; Value T.Text,
  --             in an equation for ‘cmd’
  -- ‘v’ is a rigid type variable bound by
  --    the type signature for:
  --      cmd :: forall c a v. Command c -&gt; Value a -&gt; Value v
  data Value v where
      VString     :: T.Text -&gt; Value T.Text
      VInt        :: Int -&gt; Value Int
      VBool       :: Bool -&gt; Value Bool
      VNot        :: Value Bool -&gt; Value Bool
  
  -- cmd only works with this definition
  -- with this uncommented, eval breaks with:
  -- 
  -- Couldn't match expected type ‘a’ with actual type ‘T.Text’
  --  ‘a’ is a rigid type variable bound by
  --    the type signature for:
  --       eval :: forall a. Value a -&gt; a
  -- data Value v where
  --     VString     :: T.Text -&gt; Value v
  --     VInt        :: Int -&gt; Value v
  --     VBool       :: Bool -&gt; Value v
  --     VNot        :: Value Bool -&gt; Value v
  
  eval :: Value a -&gt; a
  eval (VString i)      = i
  eval (VInt i)         = i
  eval (VBool b)        = b
  eval (VNot b)         = not $ eval b
  
  cmd :: Command c -&gt; Value a -&gt; Value v
  cmd Base64_ (VString s)         = VString $ encodeBase64 s
  cmd (_) (_)                     = VInt 3 -- or show error for no match.
  </code></pre>
  <p>Is what I'm trying to do possible? Is there a single GADT definition that would work with both <code>eval</code> and <code>cmd</code>, or am I getting one of the function signatures incorrect?</p>