I don&#39;t have an answer for you, but you might want to look at what :k does in ghci, since that needs to parse a type.<br><br><div class="gmail_quote">On Sat, Apr 23, 2011 at 2:06 PM, Ranjit Jhala <span dir="ltr">&lt;<a href="mailto:jhala@cs.ucsd.edu">jhala@cs.ucsd.edu</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Hi all,<br>
<br>
can someone give me a hint as to the best way to parse a type from a string.<br>
Ideally, I&#39;d like a function<br>
<br>
        stringType :: String -&gt; Maybe Type<br>
<br>
or possibly,<br>
<br>
        stringType :: (GhcMonad m) =&gt; String -&gt; m (Maybe Type)<br>
<br>
such that,<br>
<br>
        stringType s == Just t<br>
<br>
if in the current GHC context the string s is the name of the type t. For<br>
example, I&#39;d like:<br>
<br>
        stringType &quot;Int&quot;<br>
<br>
to return a value equal to intTy (from TysWiredIn). My investigations have<br>
led me to<br>
<br>
        parseType :: P (LHsType RdrName)<br>
<br>
and I suspect that with some work (mainly creating an appropriate PState,<br>
and mapping the name back, I can extract what I want, but I was wondering<br>
if there is some simpler route that I&#39;ve overlooked.<br>
<br>
Thanks!<br>
<br>
Ranjit.<br>
<br>
_______________________________________________<br>
Glasgow-haskell-users mailing list<br>
<a href="mailto:Glasgow-haskell-users@haskell.org">Glasgow-haskell-users@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/glasgow-haskell-users" target="_blank">http://www.haskell.org/mailman/listinfo/glasgow-haskell-users</a><br>
</blockquote></div><br>