title: Haskell type functions?
body: <p>Consider this ADT:</p>
  
  <pre><code>data Property f a = Property String (f a) | Zilch
    deriving Show
  </code></pre>
  
  <p>What is <code>f</code> here? Is it a function acting on <code>a</code>? Is it a 'type function'? The instructor said that Haskell has a Turing complete type language...so in which case the types can have functions too I assume?</p>
  
  <pre><code>*Main&gt; var = Property "Colors" [1,2,3,4]
  *Main&gt; :t var
  var :: Num a =&gt; Property [] a
  </code></pre>
  
  <p>How is <code>f</code> behaving like <code>[]</code> here? Since <code>[]</code> is the constructor for the empty list, is <code>f</code> always going to be the outermost empty constructor for the type of <code>a</code> as in the following examples?</p>
  
  <pre><code>*Main&gt; var = Property "Colors" [(1,"Red"),(2,"Blue")]
  *Main&gt; :t var
  var :: Num t =&gt; Property [] (t, [Char])
  
  *Main&gt; var = Property "Colors" (1,"Red")
  *Main&gt; :t var
  var :: Num t =&gt; Property ((,) t) [Char]
  </code></pre>
  
  <p>The latter one I don't quite get but if someone said Haskell inferred the empty constructor for that tuple, I'm okay buying that. On the other hand, </p>
  
  <pre><code>*Main&gt; var = Property "Colors" 20
  *Main&gt; :t var
  var :: Num (f a) =&gt; Property f a
  </code></pre>
  
  <p>what is <code>f</code> here? Can't be the identity because <code>id :: a -&gt; a</code> but we need <code>(f a)</code>. </p>
  
  <p>I managed to make my ADT a functor with: </p>
  
  <pre><code>instance Functor f =&gt; Functor (Property f) where
    fmap fun (Property name a) = Property name (fmap fun a)
    fmap g Zilch               = Zilch 
  </code></pre>
  
  <p>So something like the following works </p>
  
  <pre><code>*Main&gt; var = Property "Colors" [1,2,3,4]
  *Main&gt; fmap (+1) var
  Property "Colors" [2,3,4,5]
  </code></pre>
  
  <p>But what if I gave it to the previous example of a tuple? </p>
  
  <p>I am really looking for explanatory answers (have seen Haskell for barely two months in a summer course), not references to things like <code>FlexibleContexts</code> to allow ... say <code>fmap</code> to work on arbitrary <code>a</code>.</p>