<div dir="ltr">On Sun, Nov 20, 2011 at 20:36, Ben Gamari <span dir="ltr">&lt;<a href="mailto:bgamari.foss@gmail.com">bgamari.foss@gmail.com</a>&gt;</span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
expandUser :: FilePath -&gt; IO FilePath<br>
expandUser p = if &quot;~/&quot; `isPrefixOf` p<br>
                  then do u &lt;- getLoginName<br>
                          return $ u ++ drop 2 p<br>
                  else return p<br></blockquote><div><br></div><div class="gmail_quote"><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">expandUser &quot;~&quot;         = fmap homeDirectory getLoginName</font></div>
</div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">expandUser (&#39;~&#39;:&#39;/&#39;:p) = getLoginName &gt;&gt;= </font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">                         fmap ((++ p) . homeDirectory)</font></div>
<div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">                              getUserEntryForName</font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">expandUser (&#39;~&#39;:up)    = let (u,p) = break (== &#39;/&#39;) up</font></div>
<div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">                          in fmap ((++ (drop 1 p)) . homeDirectory</font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">                                  (getUserEntryForName u)</font></div>
<div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">expandUser p           = p</font></div><div><br></div></div><div>Although arguably there should be some error checking.</div><div><br></div>-- <br>
brandon s allbery                                      <a href="mailto:allbery.b@gmail.com" target="_blank">allbery.b@gmail.com</a><br>wandering unix systems administrator (available)     (412) 475-9364 vm/sms<br><br>
</div>