<!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> </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> </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> </DIV>
<DIV><FONT size=2>I : np :
<semantic term> :: Sem m a</FONT></DIV>
<DIV><FONT size=2>love : s\np : <semantic term> :: Sem m a</FONT></DIV>
<DIV><FONT size=2></FONT> </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 (->).</FONT></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><FONT size=2>I started by enumerating this by hand:</FONT></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><FONT size=2>\begin{code}</FONT></DIV>
<DIV><FONT size=2>data Monad m => Sem m a = ZSem (SST m
a)<BR> | USem (SST m a -> SST m a)<BR> |
BSem (SST m a -> SST m a -> SST m a)<BR> | TSem (SST m a
-> SST m a -> SST m a -> SST m a)<BR> | QSem (SST m a
-> SST m a -> SST m a -> SST m a -> SST m a)<BR> |
FSem (SST m a -> SST m a -> SST m a -> SST m a -> SST m a ->
SST)<BR> --<BR> | U1Sem ((SST m a -> SST m
a) -> SST m a)<BR> | B1Sem ((SST m a -> SST m a) ->
SST m a -> SST m a)<BR> | T1Sem ((SST m a -> SST m a)
-> SST m a -> SST m a -> SST m a) <BR>\end{code}</FONT></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><FONT size=2>then what I need is a function to apply these:</FONT></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><FONT size=2>\begin{code}</FONT></DIV>
<DIV><FONT size=2>applySem :: Monad m => Sem m a -> Sem m a -> 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 _
_ = error "application of Semantic
functions"<BR>\end{code}</FONT></DIV>
<DIV><FONT size=2></FONT> </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)). A complete parse will reduce the
lambda terms to closed terms containing only App and Stc, no Var or Lam. 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> </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. For theoretically complete coverage I
would need to enumerate all possible types constructed from (STT m a) and
(->). </FONT></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><FONT size=2>It seems that I must be missing something? Is there a
more elegant way of doing this?</FONT></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><FONT size=2>One can make the observation that the applySem function
always applies a function of type (b -> a) to a function of type b to
yield a function of type a.</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=2>I suppose I could write a code generator (in
haskell) that enumerates all possible derivations of (STT m a) and (->)
but there would still be 5^5 data constructors.</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=2>Thanks,</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=2>Vivian McPhail</FONT> </DIV>
<DIV><FONT size=2></FONT> </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> </DIV></DIV></BODY></HTML>