<div><div dir="auto">To be clear : I’m annoyed with myself that this impacted a package that depends on vector, but this does seem to be the case that the newest bug fix release for vector actually revealed a broken design for the vector instances / data types in the inline-r package. </div></div><div dir="auto"><br></div><div dir="auto">To;dr — I suggest patching inline-r to remove the s parameter in its immutable vector data types </div><div><br><div class="gmail_quote"><div dir="ltr">On Sat, Dec 29, 2018 at 6:48 PM Carter Schonwald <<a href="mailto:carter.schonwald@gmail.com">carter.schonwald@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr">so i took a look .. (also the inline-r devs seem to have done a hackage revision so you wont hit that issue in your current setup if you do a cabal update ..)<br></div><div>and it seems like the type definitions in inline-r are kinda bogus  and you should get them patched ...</div><div><br></div><div>the MVector type class, and related type families, all assume your mutable type has the last two arguments as the io/state token and then the element type</div><div><br></div><div>eg </div><div><a id="m_-176671679880531962gmail-v:basicLength" class="m_-176671679880531962gmail-def" style="margin:0px;padding:0px;font-weight:bold;color:rgb(0,0,0);font-family:monospace;font-size:13px">basicLength</a><span style="color:rgb(0,0,0);font-family:monospace;font-size:13px;background-color:rgb(240,240,240)"> :: v s a -> </span><a href="http://hackage.haskell.org/package/base-4.12.0.0/docs/Data-Int.html#t:Int" title="Data.Int" style="margin:0px;padding:0px;text-decoration-line:none;color:rgb(171,105,84);font-family:monospace;font-size:13px" target="_blank">Int</a><br></div><div><br></div><div><br></div><div>i looked at <a href="https://github.com/tweag/HaskellR/blob/1292c8a9562764d34ee4504b54d93248eb7346fe/inline-r/src/Data/Vector/SEXP.hs#L346-L374" target="_blank">https://github.com/tweag/HaskellR/blob/1292c8a9562764d34ee4504b54d93248eb7346fe/inline-r/src/Data/Vector/SEXP.hs#L346-L374</a> and </div><div><br></div><div><br></div><div><br></div><div>as a point of grounding this chat </div><div>the injective type familly in question is defined by the follwoing</div><div><pre style="color:rgb(0,0,0)"><span class="m_-176671679880531962gmail-hs-comment" style="color:rgb(138,138,138)"><br class="m_-176671679880531962gmail-Apple-interchange-newline">--</span>
<a name="m_-176671679880531962_line-33"></a><span class="m_-176671679880531962gmail-hs-cpp" style="color:rgb(133,153,0)">#if MIN_VERSION_base(4,9,0)
</span><span class="m_-176671679880531962gmail-hs-keyword" style="color:rgb(175,0,95)">type</span> <span class="m_-176671679880531962gmail-hs-keyword" style="color:rgb(175,0,95)">family</span> <a name="m_-176671679880531962_Mutable"></a><a href="http://hackage.haskell.org/package/vector-0.12.0.2/docs/src/Data.Vector.Generic.Base.html#Mutable" style="text-decoration-line:none;border-bottom:1px solid rgb(238,232,213)" target="_blank"><span class="m_-176671679880531962gmail-hs-identifier" style="color:rgb(7,54,66)">Mutable</span></a> <span class="m_-176671679880531962gmail-hs-special" style="color:rgb(220,50,47)">(</span><a name="m_-176671679880531962_local-6989586621679032525"></a><a href="http://hackage.haskell.org/package/vector-0.12.0.2/docs/src/Data.Vector.Generic.Base.html#local-6989586621679032525" style="text-decoration-line:none;border-bottom:1px solid rgb(238,232,213)" target="_blank"><span class="m_-176671679880531962gmail-hs-identifier" style="color:rgb(7,54,66)">v</span></a> <span class="m_-176671679880531962gmail-hs-glyph" style="color:rgb(220,50,47)">::</span> <span class="m_-176671679880531962gmail-hs-operator" style="color:rgb(211,54,130)">*</span> <span class="m_-176671679880531962gmail-hs-glyph" style="color:rgb(220,50,47)">-></span> <span class="m_-176671679880531962gmail-hs-operator" style="color:rgb(211,54,130)">*</span><span class="m_-176671679880531962gmail-hs-special" style="color:rgb(220,50,47)">)</span> <span class="m_-176671679880531962gmail-hs-glyph" style="color:rgb(220,50,47)">=</span> <span class="m_-176671679880531962gmail-hs-special" style="color:rgb(220,50,47)">(</span><a name="m_-176671679880531962_local-6989586621679032526"></a><a href="http://hackage.haskell.org/package/vector-0.12.0.2/docs/src/Data.Vector.Generic.Base.html#local-6989586621679032526" style="text-decoration-line:none;border-bottom:1px solid rgb(238,232,213)" target="_blank"><span class="m_-176671679880531962gmail-hs-identifier" style="color:rgb(7,54,66)">mv</span></a> <span class="m_-176671679880531962gmail-hs-glyph" style="color:rgb(220,50,47)">::</span> <span class="m_-176671679880531962gmail-hs-operator" style="color:rgb(211,54,130)">*</span> <span class="m_-176671679880531962gmail-hs-glyph" style="color:rgb(220,50,47)">-></span> <span class="m_-176671679880531962gmail-hs-operator" style="color:rgb(211,54,130)">*</span> <span class="m_-176671679880531962gmail-hs-glyph" style="color:rgb(220,50,47)">-></span> <span class="m_-176671679880531962gmail-hs-operator" style="color:rgb(211,54,130)">*</span><span class="m_-176671679880531962gmail-hs-special" style="color:rgb(220,50,47)">)</span> <span class="m_-176671679880531962gmail-hs-glyph" style="color:rgb(220,50,47)">|</span> <span class="m_-176671679880531962gmail-hs-identifier" style="color:rgb(7,54,66)">mv</span> <span class="m_-176671679880531962gmail-hs-glyph" style="color:rgb(220,50,47)">-></span> <span class="m_-176671679880531962gmail-hs-identifier" style="color:rgb(7,54,66)">v</span>
<a name="m_-176671679880531962_line-35"></a><span class="m_-176671679880531962gmail-hs-cpp" style="color:rgb(133,153,0)">#else
</span><span class="m_-176671679880531962gmail-hs-keyword" style="color:rgb(175,0,95)">type</span> <span class="m_-176671679880531962gmail-hs-keyword" style="color:rgb(175,0,95)">family</span> <span class="m_-176671679880531962gmail-hs-identifier" style="color:rgb(7,54,66)">Mutable</span> <span class="m_-176671679880531962gmail-hs-special" style="color:rgb(220,50,47)">(</span><span class="m_-176671679880531962gmail-hs-identifier" style="color:rgb(7,54,66)">v</span> <span class="m_-176671679880531962gmail-hs-glyph" style="color:rgb(220,50,47)">::</span> <span class="m_-176671679880531962gmail-hs-operator" style="color:rgb(211,54,130)">*</span> <span class="m_-176671679880531962gmail-hs-glyph" style="color:rgb(220,50,47)">-></span> <span class="m_-176671679880531962gmail-hs-operator" style="color:rgb(211,54,130)">*</span><span class="m_-176671679880531962gmail-hs-special" style="color:rgb(220,50,47)">)</span> <span class="m_-176671679880531962gmail-hs-glyph" style="color:rgb(220,50,47)">::</span> <span class="m_-176671679880531962gmail-hs-operator" style="color:rgb(211,54,130)">*</span> <span class="m_-176671679880531962gmail-hs-glyph" style="color:rgb(220,50,47)">-></span> <span class="m_-176671679880531962gmail-hs-operator" style="color:rgb(211,54,130)">*</span> <span class="m_-176671679880531962gmail-hs-glyph" style="color:rgb(220,50,47)">-></span> <span class="m_-176671679880531962gmail-hs-operator" style="color:rgb(211,54,130)">*</span>
<a name="m_-176671679880531962_line-37"></a><span class="m_-176671679880531962gmail-hs-cpp" style="color:rgb(133,153,0)">#endif
</span></pre>anyways, it looks like the Pure / immutable vector data type in inline-r has a spurious state token argument in its definition that shouldn't be there, OR there need to be two "s" params in inline-r instead of the one</div><div><br></div><div>heres the full code i linked to in question </div><div><br></div><div><table class="m_-176671679880531962gmail-highlight m_-176671679880531962gmail-tab-size m_-176671679880531962gmail-js-file-line-container" style="box-sizing:border-box;border-collapse:collapse;border-spacing:0px;color:rgb(36,41,46);font-family:-apple-system,system-ui,"Segoe UI",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol";font-size:14px"><tbody style="box-sizing:border-box"><tr style="box-sizing:border-box"><td id="m_-176671679880531962gmail-LC41" class="m_-176671679880531962gmail-blob-code m_-176671679880531962gmail-blob-code-inner m_-176671679880531962gmail-js-file-line m_-176671679880531962gmail-highlighted" style="box-sizing:border-box;padding:0px 10px;line-height:20px;vertical-align:top;font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:12px;overflow:visible;white-space:pre-wrap;background-color:rgb(255,251,221)"><span class="m_-176671679880531962gmail-pl-c" style="box-sizing:border-box;color:rgb(106,115,125)"><span class="m_-176671679880531962gmail-pl-c" style="box-sizing:border-box"><br class="m_-176671679880531962gmail-Apple-interchange-newline">--</span> <span class="m_-176671679880531962gmail-pl-c" style="box-sizing:border-box">|</span> Mutable R vector. Represented in memory with the same header as 'SEXP'</span></td></tr><tr style="box-sizing:border-box"><td id="m_-176671679880531962gmail-L42" class="m_-176671679880531962gmail-blob-num m_-176671679880531962gmail-js-line-number" style="box-sizing:border-box;padding:0px 10px;line-height:20px;min-width:50px;vertical-align:top;width:50px"><br>-- nodes. The second type parameter is phantom, reflecting at the type level the<br>-- tag of the vector when viewed as a 'SEXP'. The tag of the vector and the<br>-- representation type are related via 'ElemRep'.<br>data MVector s ty a = MVector<br>{ mvectorBase :: {-# UNPACK #-} !(SEXP s ty)<br>, mvectorOffset :: {-# UNPACK #-} !Int32<br>, mvectorLength :: {-# UNPACK #-} !Int32<br>}<br>-- | Internal wrapper type for reflection. First type parameter is the reified<br>-- type to reflect.<br>newtype W t ty s a = W { unW :: MVector s ty a }<br>instance (Reifies t (AcquireIO s), VECTOR s ty a) => G.MVector (W t ty) a where<br></td><td id="m_-176671679880531962gmail-LC42" class="m_-176671679880531962gmail-blob-code m_-176671679880531962gmail-blob-code-inner m_-176671679880531962gmail-js-file-line m_-176671679880531962gmail-highlighted" style="box-sizing:border-box;padding:0px 10px;line-height:20px;vertical-align:top;font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:12px;overflow:visible;white-space:pre-wrap;background-color:rgb(255,251,221)"></td></tr></tbody></table><br></div><div><table class="m_-176671679880531962gmail-highlight m_-176671679880531962gmail-tab-size m_-176671679880531962gmail-js-file-line-container" style="box-sizing:border-box;border-collapse:collapse;border-spacing:0px;color:rgb(36,41,46);font-family:-apple-system,system-ui,"Segoe UI",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol";font-size:14px"><tbody style="box-sizing:border-box"><tr style="box-sizing:border-box"></tr><tr style="box-sizing:border-box"><td id="m_-176671679880531962gmail-LC346" class="m_-176671679880531962gmail-blob-code m_-176671679880531962gmail-blob-code-inner m_-176671679880531962gmail-js-file-line m_-176671679880531962gmail-highlighted" style="box-sizing:border-box;padding:0px 10px;line-height:20px;vertical-align:top;font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:12px;overflow:visible;white-space:pre-wrap;background-color:rgb(255,251,221)"><span class="m_-176671679880531962gmail-pl-k" style="box-sizing:border-box;color:rgb(215,58,73)">data</span> <span class="m_-176671679880531962gmail-pl-en" style="box-sizing:border-box;color:rgb(111,66,193)">Vector</span> <span class="m_-176671679880531962gmail-pl-smi" style="box-sizing:border-box">s</span> (<span class="m_-176671679880531962gmail-pl-smi" style="box-sizing:border-box">ty</span> <span class="m_-176671679880531962gmail-pl-k" style="box-sizing:border-box;color:rgb(215,58,73)">::</span> <span class="m_-176671679880531962gmail-pl-en" style="box-sizing:border-box;color:rgb(111,66,193)">SEXPTYPE</span>) <span class="m_-176671679880531962gmail-pl-smi" style="box-sizing:border-box">a</span> <span class="m_-176671679880531962gmail-pl-k" style="box-sizing:border-box;color:rgb(215,58,73)">=</span> <span class="m_-176671679880531962gmail-pl-ent" style="box-sizing:border-box;color:rgb(34,134,58)">Vector</span></td></tr><tr style="box-sizing:border-box"><td id="m_-176671679880531962gmail-L347" class="m_-176671679880531962gmail-blob-num m_-176671679880531962gmail-js-line-number" style="box-sizing:border-box;padding:0px 10px;line-height:20px;min-width:50px;vertical-align:top;width:50px">    { vectorBase :: {-# UNPACK #-} !(ForeignSEXP ty) , vectorOffset :: {-# UNPACK #-} !Int32 , vectorLength :: {-# UNPACK #-} !Int32<br></td><td id="m_-176671679880531962gmail-LC347" class="m_-176671679880531962gmail-blob-code m_-176671679880531962gmail-blob-code-inner m_-176671679880531962gmail-js-file-line m_-176671679880531962gmail-highlighted" style="box-sizing:border-box;padding:0px 10px;line-height:20px;vertical-align:top;font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:12px;overflow:visible;white-space:pre-wrap;background-color:rgb(255,251,221)"></td></tr><tr style="box-sizing:border-box"><td id="m_-176671679880531962gmail-L350" class="m_-176671679880531962gmail-blob-num m_-176671679880531962gmail-js-line-number" style="box-sizing:border-box;padding:0px 10px;color:rgba(27,31,35,0.3);font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:12px;line-height:20px;min-width:50px;text-align:right;vertical-align:top;white-space:nowrap;width:50px"></td><td id="m_-176671679880531962gmail-LC350" class="m_-176671679880531962gmail-blob-code m_-176671679880531962gmail-blob-code-inner m_-176671679880531962gmail-js-file-line m_-176671679880531962gmail-highlighted" style="box-sizing:border-box;padding:0px 10px;line-height:20px;vertical-align:top;font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:12px;overflow:visible;white-space:pre-wrap;background-color:rgb(255,251,221)">  <span class="m_-176671679880531962gmail-pl-k" style="box-sizing:border-box;color:rgb(215,58,73)">}</span></td></tr><tr style="box-sizing:border-box"><td id="m_-176671679880531962gmail-L351" class="m_-176671679880531962gmail-blob-num m_-176671679880531962gmail-js-line-number" style="box-sizing:border-box;padding:0px 10px;color:rgba(27,31,35,0.3);font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:12px;line-height:20px;min-width:50px;text-align:right;vertical-align:top;white-space:nowrap;width:50px"></td></tr></tbody></table><br><table class="m_-176671679880531962gmail-highlight m_-176671679880531962gmail-tab-size m_-176671679880531962gmail-js-file-line-container" style="box-sizing:border-box;border-collapse:collapse;border-spacing:0px;color:rgb(36,41,46);font-family:-apple-system,system-ui,"Segoe UI",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol";font-size:14px"><tbody style="box-sizing:border-box"><tr style="box-sizing:border-box"><td id="m_-176671679880531962gmail-LC374" class="m_-176671679880531962gmail-blob-code m_-176671679880531962gmail-blob-code-inner m_-176671679880531962gmail-js-file-line m_-176671679880531962gmail-highlighted" style="box-sizing:border-box;padding:0px 10px;line-height:20px;vertical-align:top;font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:12px;overflow:visible;white-space:pre-wrap;background-color:rgb(255,251,221)"><span class="m_-176671679880531962gmail-pl-k" style="box-sizing:border-box;color:rgb(215,58,73)"><br class="m_-176671679880531962gmail-Apple-interchange-newline">type</span> <span class="m_-176671679880531962gmail-pl-k" style="box-sizing:border-box;color:rgb(215,58,73)">instance</span> <span class="m_-176671679880531962gmail-pl-en" style="box-sizing:border-box;color:rgb(111,66,193)"><span class="m_-176671679880531962gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,92,197)">G.</span>Mutable</span> (<span class="m_-176671679880531962gmail-pl-en" style="box-sizing:border-box;color:rgb(111,66,193)">W</span> <span class="m_-176671679880531962gmail-pl-smi" style="box-sizing:border-box">t</span> <span class="m_-176671679880531962gmail-pl-smi" style="box-sizing:border-box">ty</span> <span class="m_-176671679880531962gmail-pl-smi" style="box-sizing:border-box">s</span>) <span class="m_-176671679880531962gmail-pl-k" style="box-sizing:border-box;color:rgb(215,58,73)">=</span> <span class="m_-176671679880531962gmail-pl-en" style="box-sizing:border-box;color:rgb(111,66,193)"><span class="m_-176671679880531962gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,92,197)">Mutable.</span>W</span> <span class="m_-176671679880531962gmail-pl-smi" style="box-sizing:border-box">t</span> <span class="m_-176671679880531962gmail-pl-smi" style="box-sizing:border-box">ty
</span></td></tr></tbody></table><br class="m_-176671679880531962gmail-Apple-interchange-newline"></div><div>Anyways, the fix here is to remove the s param from the Pure version of W and "Sexp Vector"</div><div><br></div><div><br></div></div></div><br><div class="gmail_quote"><div dir="ltr">On Sat, Dec 29, 2018 at 6:16 PM Carter Schonwald <<a href="mailto:carter.schonwald@gmail.com" target="_blank">carter.schonwald@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>were you using the same version of vector in both setups?</div><div><br></div>in the most recent  vector release  we made mutable type family injective in the vector package for ghc's that support it ...</div><br><div class="gmail_quote"><div dir="ltr">On Sat, Dec 29, 2018 at 1:50 PM Dominick Samperi <<a href="mailto:djsamperi@gmail.com" target="_blank">djsamperi@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">When I use v8.6.3 of GHC under Ubuntu to install the inline-r package<br>
I get the error "Type family equation violates injectivity annotation," and<br>
a type variable on the LHS cannot be inferred from the RHS, due to<br>
the lack of injectivity (I suppose).<br>
<br>
On the other hand, v8.0.2 of GHC (shipped with Haskell Platform under<br>
Ubuntu) does not have this problem (it has other problems).<br>
<br>
Has something changed in the latest version of the compiler that might<br>
cause this? Possible work-around?<br>
<br>
FYI, the line that triggers the error is:<br>
type instance G.Mutable (W t ty s) = Mutable.W t ty<br>
<br>
The variable that cannot be inferred is 's'.<br>
<br>
Thanks,<br>
Dominick<br>
_______________________________________________<br>
ghc-devs mailing list<br>
<a href="mailto:ghc-devs@haskell.org" target="_blank">ghc-devs@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs</a><br>
</blockquote></div>
</blockquote></div>
</blockquote></div></div>