<div dir="ltr"><span style="font-family:arial,sans-serif;font-size:13px">Yep, search for the standard examples of Phantom Types.</span><br><div><span style="font-family:arial,sans-serif;font-size:13px"><br></span></div><div style>

<span style="font-family:arial,sans-serif;font-size:13px">Peter</span></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On 21 December 2012 20:49, Mike Meyer <span dir="ltr">&lt;<a href="mailto:mwm@mired.org" target="_blank">mwm@mired.org</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">While thinking about my next blog posting, I realized that it was a<br>
technique similar to what Perl does with the concept of &quot;tainted&quot;<br>
strings.<br>
<br>
If you&#39;re not familiar with it  (and I&#39;m probably getting the details<br>
wrong, not having written any perl in decades), a string that comes<br>
from an external source is considered &quot;tainted&quot;. String constants in<br>
the program source are not. There&#39;s a builtin that can be used to say<br>
that declares a tainted string as not being tainted (presumably, the<br>
programmer has examined it somehow to determine this). Any string<br>
operations that return strings return tainted strings if any of the<br>
strings involved were tainted. Finally, functions that are subject to<br>
data injection attacks don&#39;t work on tainted strings.<br>
<br>
It seems like the Haskell type system ought to be able to support<br>
this. I can see a couple of approaches that might work (a &quot;tainted&quot;<br>
monad for use on the different string types or an Either-ish datatype)<br>
that might work, but don&#39;t have the chops to decide which approach<br>
might be better - or maybe that the answer is that it depends on the<br>
goal.<br>
<br>
I did some googling for this, but didn&#39;t turn up anything that seemed<br>
promising. Lots of stuff on type checking untrusted values, but no<br>
flagging strings as untrusted. Which leaves the questions...<br>
<br>
Is this actually a sane idea?<br>
<br>
Is there already a Haskell package that does this? Possibly part of a<br>
web framework?<br>
<br>
A package for another language, or a paper discussing doing this?<br>
<br>
Thoughts on other approaches than the two I mentioned?<br>
<br>
Thoughts on the best way do to do this?<br>
<br>
    Thanks,<br>
    &lt;mike<br>
<br>
_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org">Beginners@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/beginners" target="_blank">http://www.haskell.org/mailman/listinfo/beginners</a><br>
</blockquote></div><br></div>