<div dir="ltr">Not that I really want to encourage such a "stringly typed" practice, but it wouldn't really be that much of a stretch.<br><br>* Use haskell-src-exts[0] and haskell-src-meta[1] to make a quasiquoter that can parse Haskell syntax<br>
* Use syb[2] or some other generics to find VarE and ConE expressions. In order to use SYB with TH, you'll want th-orphans[3]<br>* Use 'reify'[4] on the name of the variable or constructor, to see if it exists. If it doesn't[5], replace it with (LitE (StringL (nameBase name)))<br>
<br>Shouldn't really be much code at all! :D<br><br>-Michael<br><br>[0] <a href="http://hackage.haskell.org/package/haskell-src-exts">http://hackage.haskell.org/package/haskell-src-exts</a><br>[1] <a href="http://hackage.haskell.org/package/haskell-src-meta">http://hackage.haskell.org/package/haskell-src-meta</a><br>
[2] <a href="http://hackage.haskell.org/package/syb">http://hackage.haskell.org/package/syb</a><br>[3] <a href="http://hackage.haskell.org/package/th-orphans">http://hackage.haskell.org/package/th-orphans</a><br>[4] <a href="http://hackage.haskell.org/packages/archive/template-haskell/latest/doc/html/Language-Haskell-TH.html#v:reify">http://hackage.haskell.org/packages/archive/template-haskell/latest/doc/html/Language-Haskell-TH.html#v:reify</a><br>
[5] <a href="http://byorgey.wordpress.com/2011/08/16/idempotent-template-haskell/">http://byorgey.wordpress.com/2011/08/16/idempotent-template-haskell/</a></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sat, Aug 31, 2013 at 11:41 PM, Mateusz Kowalczyk <span dir="ltr"><<a href="mailto:fuuzetsu@fuuzetsu.co.uk" target="_blank">fuuzetsu@fuuzetsu.co.uk</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">On 01/09/13 07:02, yi lu wrote:<br>
> I want to know if it is possible that I use strings without "".<br>
><br>
> If I type<br>
</div>> *Prelude>foo bar*<br>
> which actually I mean<br>
> *Prelude>foo "bar"*<br>
<div class="im">> However I don't want to type ""s.<br>
><br>
</div>> I have noticed if *bar* is predefined or it is a number, it can be used as<br>
<div class="im">> arguments. But can other strings be used this way? Like in bash, we can use<br>
</div>> *ping 127.0.0.1* where *127.0.0.1* is an argument.<br>
><br>
> If not, can *foo* be defined as a function so that it recognize arguments<br>
> like *bar* as *"bar"*?<br>
><br>
><br>
> Thanks,<br>
> Yi Lu<br>
><br>
><br>
You can't do this non-trivially. I think your only bet would be Template<br>
Haskell using the second approach and even then, it's a huge, huge<br>
stretch. I highly recommend against such ideas though. Do you really<br>
want anything that's not bound to be treated as a String? (The answer is<br>
‘no’). I suggest that you get used to ‘"’s.<br>
<br>
If you have deep hatred for ‘"’, you could resort to spelling out the<br>
strings like ['f', 'o', 'o'] or even 'f':'o':'o':[].<br>
<br>
It's a bit like asking whether you can do addition everywhere by just<br>
typing the numbers to each other (no cheating and defining number<br>
literals as functions ;) ).<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
Mateusz K.<br>
<br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
</font></span></blockquote></div><br></div>