Note that there are some explanatory texts on larger screens.

plurals
  1. POnarrowing type of a vinyl record based on the lens/index chosen
    primarykey
    data
    text
    <p>Extensible records provided by <a href="http://hackage.haskell.org/package/vinyl" rel="nofollow">http://hackage.haskell.org/package/vinyl</a> are different from what other libraries (HList and probably others like grapefruit-records/records) provide. This is because the result of the lookup is based on the pair <code>(result type, label)</code>, while the other libraries have the lookup based on <code>label</code> only. An example of this happening for vinyl:</p> <pre><code>{-# LANGUAGE DataKinds, TypeOperators #-} import Data.Vinyl r = fixRecord $ (Field :: "x" ::: a) =: (3::Double) &lt;+&gt; (Field :: "x" ::: a) =: (2::Int) main = do print $ rGet (Field :: "x" ::: Int) r print $ rGet (Field :: "x" ::: Double) r -- prints 2\n3 </code></pre> <p>For my application <a href="http://hackage.haskell.org/package/Rlang-QQ" rel="nofollow">http://hackage.haskell.org/package/Rlang-QQ</a>, the type of the elements of the record will be determined by their usage later on, so it seems I need the "x" to uniquely determine the value that's stored there.</p> <p>I want to avoid "redundant" type signature in the expression</p> <pre><code>(rGet (Field :: "z" ::: [Double]) (ans :: PlainRec ("z" ::: [Double] ': '[]))) </code></pre> <p>and have it look more like:</p> <pre><code>(rGet (Field :: "z" ::: [Double]) ans) </code></pre> <p>The whole code is in <a href="http://code.haskell.org/~aavogt/Rlang-QQ/examples/test2.hs" rel="nofollow">http://code.haskell.org/~aavogt/Rlang-QQ/examples/test2.hs</a> Is there some way to achieve this using vinyl, or should I adapt my code to use another library?</p>
    singulars
    1. This table or related slice is empty.
    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