[Haskell-cafe] Can I use String without "" in ghci?
mgsloan at gmail.com
Sun Sep 1 18:29:44 CEST 2013
Not that I really want to encourage such a "stringly typed" practice, but
it wouldn't really be that much of a stretch.
* Use haskell-src-exts and haskell-src-meta to make a quasiquoter
that can parse Haskell syntax
* Use syb or some other generics to find VarE and ConE expressions. In
order to use SYB with TH, you'll want th-orphans
* Use 'reify' on the name of the variable or constructor, to see if it
exists. If it doesn't, replace it with (LitE (StringL (nameBase name)))
Shouldn't really be much code at all! :D
On Sat, Aug 31, 2013 at 11:41 PM, Mateusz Kowalczyk <fuuzetsu at fuuzetsu.co.uk
> On 01/09/13 07:02, yi lu wrote:
> > I want to know if it is possible that I use strings without "".
> > If I type
> > *Prelude>foo bar*
> > which actually I mean
> > *Prelude>foo "bar"*
> > However I don't want to type ""s.
> > I have noticed if *bar* is predefined or it is a number, it can be used
> > arguments. But can other strings be used this way? Like in bash, we can
> > *ping 127.0.0.1* where *127.0.0.1* is an argument.
> > If not, can *foo* be defined as a function so that it recognize arguments
> > like *bar* as *"bar"*?
> > Thanks,
> > Yi Lu
> You can't do this non-trivially. I think your only bet would be Template
> Haskell using the second approach and even then, it's a huge, huge
> stretch. I highly recommend against such ideas though. Do you really
> want anything that's not bound to be treated as a String? (The answer is
> ‘no’). I suggest that you get used to ‘"’s.
> If you have deep hatred for ‘"’, you could resort to spelling out the
> strings like ['f', 'o', 'o'] or even 'f':'o':'o':.
> It's a bit like asking whether you can do addition everywhere by just
> typing the numbers to each other (no cheating and defining number
> literals as functions ;) ).
> Mateusz K.
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe