<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2800.1498" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT size=2>Hi,</FONT></DIV>
<DIV><FONT size=2></FONT>&nbsp;</DIV>
<DIV><FONT size=2>I am writing a NL parser in Haskell, relying on combinatorial 
grammar for the syntactic derivation.</FONT></DIV>
<DIV><FONT size=2></FONT>&nbsp;</DIV>
<DIV><FONT size=2>Each word has an associated syntax and semantics, the semantic 
term is a lambda expression loaded at run-time using hs-plugins.</FONT></DIV>
<DIV><FONT size=2></FONT>&nbsp;</DIV>
<DIV><FONT size=2>I&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : np&nbsp;&nbsp;&nbsp;: 
&lt;semantic term&gt; :: Sem m a</FONT></DIV>
<DIV><FONT size=2>love : s\np : &lt;semantic term&gt; :: Sem m a</FONT></DIV>
<DIV><FONT size=2></FONT>&nbsp;</DIV>
<DIV><FONT size=2>Predicates in english can have up to 5 arguments, and some of 
these arguments are functions, so the type of Sem m a is an enumeration of the 
types that we can build up from (STT m a) and (-&gt;).</FONT></DIV>
<DIV><FONT size=2></FONT>&nbsp;</DIV>
<DIV><FONT size=2>I started by enumerating this by hand:</FONT></DIV>
<DIV><FONT size=2></FONT>&nbsp;</DIV>
<DIV><FONT size=2>\begin{code}</FONT></DIV>
<DIV><FONT size=2>data Monad m =&gt; Sem m a = ZSem (SST m 
a)<BR>&nbsp;&nbsp;&nbsp;| USem (SST m a -&gt; SST m a)<BR>&nbsp;&nbsp;&nbsp;| 
BSem (SST m a -&gt; SST m a -&gt; SST m a)<BR>&nbsp;&nbsp;&nbsp;| TSem (SST m a 
-&gt; SST m a -&gt; SST m a -&gt; SST m a)<BR>&nbsp;&nbsp;&nbsp;| QSem (SST m a 
-&gt; SST m a -&gt; SST m a -&gt; SST m a -&gt; SST m a)<BR>&nbsp;&nbsp;&nbsp;| 
FSem (SST m a -&gt; SST m a -&gt; SST m a -&gt; SST m a -&gt; SST m a -&gt; 
SST)<BR>&nbsp;&nbsp;&nbsp;--<BR>&nbsp;&nbsp;&nbsp;| U1Sem ((SST m a -&gt; SST m 
a) -&gt; SST m a)<BR>&nbsp;&nbsp;&nbsp;| B1Sem ((SST m a -&gt; SST m a) -&gt; 
SST m a -&gt; SST m a)<BR>&nbsp;&nbsp;&nbsp;| T1Sem ((SST m a -&gt; SST m a) 
-&gt; SST m a -&gt; SST m a -&gt; SST m a) <BR>\end{code}</FONT></DIV>
<DIV><FONT size=2></FONT>&nbsp;</DIV>
<DIV><FONT size=2>then what I need is a function to apply these:</FONT></DIV>
<DIV><FONT size=2></FONT>&nbsp;</DIV>
<DIV><FONT size=2>\begin{code}</FONT></DIV>
<DIV><FONT size=2>applySem :: Monad m =&gt; Sem m a -&gt; Sem m a -&gt; Sem m 
a<BR>applySem (USem a) (ZSem b) = ZSem $ a b<BR>applySem (BSem a) (ZSem b) = 
USem $ a b<BR>applySem (TSem a) (ZSem b) = BSem $ a b<BR>applySem (QSem a) (ZSem 
b) = TSem $ a b<BR>applySem (U1Sem a) (USem b) = ZSem # a b <BR>applySem (B1Sem 
a) (USem b) = USem $ a b<BR>applySem (T1Sem a) (USem b) = BSem $ a b<BR>applySem 
(T2Sem a) (ZSem b) = B1Sem $ a b<BR>applySem (B12Sem a) (USem b) = U1Sem $ a 
b<BR>applySem _&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
_&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = error "application of Semantic 
functions"<BR>\end{code}</FONT></DIV>
<DIV><FONT size=2></FONT>&nbsp;</DIV>
<DIV><FONT size=2>My typing system ensures that only the correct functions will 
be applied to each other (the typing system manipulates lambda terms with an 
additional type (Stc Name (Sem m a)).&nbsp; A complete parse will reduce the 
lambda terms to closed terms containing only App and Stc, no Var or Lam.&nbsp; I 
can then use applySem to reduce the term to a single (Sem m a) type, which I can 
then run.</FONT></DIV>
<DIV><FONT size=2></FONT>&nbsp;</DIV>
<DIV><FONT size=2>What I have done thus far is enumerate by hand, but for full 
coverage for 5 argument predicates I need to list 5^5 data constructors and 
entries in the applySem function.&nbsp; For theoretically complete coverage I 
would need to enumerate all&nbsp;possible types constructed from (STT m a) and 
(-&gt;).&nbsp;</FONT></DIV>
<DIV><FONT size=2></FONT>&nbsp;</DIV>
<DIV><FONT size=2>It seems that I must be missing something?&nbsp; Is there a 
more elegant way of doing this?</FONT></DIV>
<DIV><FONT size=2></FONT>&nbsp;</DIV>
<DIV><FONT size=2>One can make the observation that the applySem function 
always&nbsp;applies a function of type (b -&gt; a) to a function of type b to 
yield a&nbsp;function of type a.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT size=2>I&nbsp;suppose I could write a code&nbsp;generator (in 
haskell) that enumerates all possible&nbsp;derivations of (STT m a) and (-&gt;) 
but there would still be 5^5 data constructors.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT size=2>Thanks,</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT size=2>Vivian McPhail</FONT>&nbsp;</DIV>
<DIV><FONT size=2></FONT>&nbsp;</DIV>
<DIV>
<DIV><FONT size=2>PS Is there something I can do with the Typeable class of 
hs-plugins?</FONT></DIV>
<DIV><FONT size=2></FONT>&nbsp;</DIV></DIV></BODY></HTML>