Note that there are some explanatory texts on larger screens.

plurals
  1. POHaskell type enforcement on typeclass parameters
    primarykey
    data
    text
    <p>I am trying to follow along a machine learning book and knowing a bit about the future content I am trying make my code generalisable.</p> <p>Here is my code. I will eventually have other instances of DataSet, but this is all I have for now.</p> <pre><code>data SupervisedDataSet x y = SupervisedDataSet [([x], y)] deriving (Show) class DataSet a where augment :: x -&gt; a -&gt; a --Augment each input vector, making x the head. instance DataSet (SupervisedDataSet x y) where augment v (SupervisedDataSet ds) =· let xsys = unzip ds in SupervisedDataSet $ zip (map (v:) $ fst xsys) (snd xsys) </code></pre> <p>I am trying to enforce the type of the first parameter of <code>SupervisedDataSet</code> with the first parameter of <code>augment</code> as requested by the type checker in GHC.</p> <pre><code>Perceptron.hs:16:7: Couldn't match type `x1' with `x' `x1' is a rigid type variable bound by the type signature for agument :: x1 -&gt; SupervisedDataSet x y -&gt; SupervisedDataSet x y at Perceptron.hs:14:3 `x' is a rigid type variable bound by the instance declaration at Perceptron.hs:13:37 Expected type: SupervisedDataSet x1 y Actual type: SupervisedDataSet x y In the expression: SupervisedDataSet $ zip (map (v :) $ fst xsys) (snd xsys) In the expression: let xsys = unzip ds in SupervisedDataSet $ zip (map (v :) $ fst xsys) (snd xsys) </code></pre> <p>I understand why I am receiving the error, I just don't know how to fix it. Any ideas would be appreciated. Thanks</p> <p>Thanks for your time.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload