<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body><div><div style="font-family: Calibri,sans-serif; font-size: 11pt;">I think that the whole point of extensible records is to change the type on appending, to provide more safety at compile time than (hash) maps. If you don't want to use lenses (zoom) to combine different state monads, I guess a map is the best option.<br><br>Kind regards,<br>Marcin Mrotek</div></div><div dir="ltr"><hr><span style="font-family: Calibri,sans-serif; font-size: 11pt; font-weight: bold;">Od: </span><span style="font-family: Calibri,sans-serif; font-size: 11pt;"><a href="mailto:agocorona@gmail.com">Alberto G. Corona </a></span><br><span style="font-family: Calibri,sans-serif; font-size: 11pt; font-weight: bold;">Wysłano: </span><span style="font-family: Calibri,sans-serif; font-size: 11pt;">‎2015-‎05-‎05 23:03</span><br><span style="font-family: Calibri,sans-serif; font-size: 11pt; font-weight: bold;">Do: </span><span style="font-family: Calibri,sans-serif; font-size: 11pt;"><a href="mailto:marcin.jan.mrotek@gmail.com">Marcin Mrotek</a></span><br><span style="font-family: Calibri,sans-serif; font-size: 11pt; font-weight: bold;">DW: </span><span style="font-family: Calibri,sans-serif; font-size: 11pt;"><a href="mailto:vogt.adam@gmail.com">adam vogt</a>; <a href="mailto:haskell-cafe@haskell.org">haskell-cafe</a></span><br><span style="font-family: Calibri,sans-serif; font-size: 11pt; font-weight: bold;">Temat: </span><span style="font-family: Calibri,sans-serif; font-size: 11pt;">Re: [Haskell-cafe] Extensible states</span><br><br></div><div dir="ltr"><div>Thanks all of you.</div><div><br></div>So there is no trick that can make extensible records O(1) for field access, like the native haskell records?. I didn´t know that all the extensible records have  O(n) or O(log n) at most.<div><br></div><div>That is not better than my State monad with a Data.Map.  It is not possible to use HList-like records like the one that Adam mentioned since the type signature must not change when a new field is added.<br></div></div><div class="gmail_extra"><br><div class="gmail_quote">2015-05-05 22:20 GMT+02:00 Marcin Mrotek <span dir="ltr"><<a href="mailto:marcin.jan.mrotek@gmail.com" target="_blank">marcin.jan.mrotek@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-left-color: rgb(204, 204, 204); border-left-width: 1px; border-left-style: solid;"><div dir="ltr"><div class="gmail_extra">Hello,</div><div class="gmail_extra"><br></div><div class="gmail_extra">I'm not sure if this is what you're looking for, but vinyl + lens state monad combinators let you write something like this:</div><div class="gmail_extra"><br></div><div class="gmail_extra">foo :: State (Rec Foo [B,C,F]) Bar</div><div class="gmail_extra">foo = ...</div><div class="gmail_extra"><br></div><div class="gmail_extra">bar = State (Rec Foo [A,B,C,D,E,F]</div><div class="gmail_extra">bar = do</div><div class="gmail_extra">   ...</div><div class="gmail_extra">   x <- zoom rsubset foo</div><div class="gmail_extra">   ...</div><div class="gmail_extra">   rlens SA .= 3</div><div class="gmail_extra">   ...</div><div class="gmail_extra"><br></div><div class="gmail_extra">Unfortunately Vinyl has O(n) lookup (unless it gets optimized away by sufficiently glorious haskell compiler, I guess, but I have no idea whether it actually can happen). But I'm not sure if the speed impact is noticeable, compared to using monad transformer stacks, for example.</div><div class="gmail_extra"><br></div><div class="gmail_extra"><a href="http://hackage.haskell.org/package/vinyl" target="_blank">http://hackage.haskell.org/package/vinyl</a><br></div><div class="gmail_extra"><a href="http://hackage.haskell.org/package/vinyl-0.5.1/docs/Data-Vinyl-Lens.html" target="_blank">http://hackage.haskell.org/package/vinyl-0.5.1/docs/Data-Vinyl-Lens.html</a><br></div><div class="gmail_extra"><a href="http://hackage.haskell.org/package/lens" target="_blank">http://hackage.haskell.org/package/lens</a><br></div><div class="gmail_extra"><a href="https://www.fpcomplete.com/school/to-infinity-and-beyond/pick-of-the-week/a-little-lens-starter-tutorial" target="_blank">https://www.fpcomplete.com/school/to-infinity-and-beyond/pick-of-the-week/a-little-lens-starter-tutorial</a><br></div><div class="gmail_extra"><br></div><div class="gmail_extra">Best regards,</div><div class="gmail_extra">Marcin Mrotek</div></div>
<br>_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature">Alberto.</div>
</div>
</body></html>