Loading ...
Sorry, an error occurred while loading the content.

How to prevent duplicate list items?

Expand Messages
  • cp200205
    I have code such as: newtype Bottle = Bot Int data Line = Simple String | Complex Bottle String verse n = 10 Now, in Haskell newtype creates a new type by the
    Message 1 of 3 , Feb 13, 2004
    • 0 Attachment
      I have code such as:

      newtype Bottle = Bot Int
      data Line = Simple String | Complex Bottle String
      verse n = 10

      Now, in Haskell newtype creates a new type by the name given
      (Bottle) and data creates a data statement by the name given (Line)
      but all other constructs on the first col are variables.

      So, I would like my Item list to show something like:

      type Bottle
      data Line
      var verse n

      Now, I accomplished that, however, I also have two other items
      appearing which should not:

      var type Bottle
      var data Line

      Here is my itemlist setup:

      set-variable .fhook-haskell.item-list-s1 "^\\(\\w*\\)[ \t]*="
      set-variable .fhook-haskell.item-list-r1 "\ecBvar \\1\ecA"
      set-variable .fhook-haskell.item-list-s2 "^data \\(\\w.*\\)[ \t]*="
      set-variable .fhook-haskell.item-list-r2 "\ecBdata \\1\ecA"
      set-variable .fhook-haskell.item-list-s3 "^newtype \\(\\w.*\\)
      [ \t]*="
      set-variable .fhook-haskell.item-list-r3 "\ecBtype \\1\ecA"

      I can see why type and data lines are being matched twice, but I
      have tried many methods to cause the var entry to *not* match
      anything begining with data or newtype.

      Does anyone know how to accomplish this?

      Jeremy
    • Jon Green
      ... This is tricky as the var Regular Expression is more than a little ambiguous. You need to firm it up a bit, which will cost in processing time. So for
      Message 2 of 3 , Feb 13, 2004
      • 0 Attachment
        cp200205 wrote:
        > I have code such as:
        >
        > newtype Bottle = Bot Int
        > data Line = Simple String | Complex Bottle String
        > verse n = 10
        >
        > Now, in Haskell newtype creates a new type by the name given
        > (Bottle) and data creates a data statement by the name given (Line)
        > but all other constructs on the first col are variables.
        >
        > So, I would like my Item list to show something like:
        >
        > type Bottle
        > data Line
        > var verse n
        >
        > Now, I accomplished that, however, I also have two other items
        > appearing which should not:
        >
        > var type Bottle
        > var data Line
        >
        > Here is my itemlist setup:
        >
        > set-variable .fhook-haskell.item-list-s1 "^\\(\\w*\\)[ \t]*="
        > set-variable .fhook-haskell.item-list-r1 "\ecBvar \\1\ecA"
        > set-variable .fhook-haskell.item-list-s2 "^data \\(\\w.*\\)[ \t]*="
        > set-variable .fhook-haskell.item-list-r2 "\ecBdata \\1\ecA"
        > set-variable .fhook-haskell.item-list-s3 "^newtype \\(\\w.*\\)
        > [ \t]*="
        > set-variable .fhook-haskell.item-list-r3 "\ecBtype \\1\ecA"
        >
        > I can see why type and data lines are being matched twice, but I
        > have tried many methods to cause the var entry to *not* match
        > anything begining with data or newtype.
        >
        > Does anyone know how to accomplish this?
        >
        > Jeremy
        >
        >

        This is tricky as the "var" Regular Expression is more than a
        little ambiguous. You need to firm it up a bit, which will
        cost in processing time. So for the "var" you could do
        something rather gross like:

        "^\\([^nd]\\w*\\|[dn][^ae]\\w*\\|de\\w*\\|na\\w*\\|da\\|ne\\)[ \t]+\\w+[
        \t]*="

        Which would probably work for most cases, there are a few exections
        but the RE becomes quite long if you want to catch them all. This
        would probably do.

        Infact what you posted is incorrect is it not "\(\w+[ \t]\w+[ \t]*="
        for the var search ?

        Jon.
      • Jon Green
        ... While I remember.... The [^nd] is bad as it matches too much, need [a-ce-mo-z] etc. But you should get the idea. Jon.
        Message 3 of 3 , Feb 13, 2004
        • 0 Attachment
          Jon Green wrote:
          > cp200205 wrote:
          >
          >>I have code such as:
          >>
          >>newtype Bottle = Bot Int
          >>data Line = Simple String | Complex Bottle String
          >>verse n = 10
          >>
          >>Now, in Haskell newtype creates a new type by the name given
          >>(Bottle) and data creates a data statement by the name given (Line)
          >>but all other constructs on the first col are variables.
          >>
          >>So, I would like my Item list to show something like:
          >>
          >>type Bottle
          >>data Line
          >>var verse n
          >>
          >>Now, I accomplished that, however, I also have two other items
          >>appearing which should not:
          >>
          >>var type Bottle
          >>var data Line
          >>
          >>Here is my itemlist setup:
          >>
          >>set-variable .fhook-haskell.item-list-s1 "^\\(\\w*\\)[ \t]*="
          >>set-variable .fhook-haskell.item-list-r1 "\ecBvar \\1\ecA"
          >>set-variable .fhook-haskell.item-list-s2 "^data \\(\\w.*\\)[ \t]*="
          >>set-variable .fhook-haskell.item-list-r2 "\ecBdata \\1\ecA"
          >>set-variable .fhook-haskell.item-list-s3 "^newtype \\(\\w.*\\)
          >>[ \t]*="
          >>set-variable .fhook-haskell.item-list-r3 "\ecBtype \\1\ecA"
          >>
          >>I can see why type and data lines are being matched twice, but I
          >>have tried many methods to cause the var entry to *not* match
          >>anything begining with data or newtype.
          >>
          >>Does anyone know how to accomplish this?
          >>
          >>Jeremy
          >>
          >>
          >
          >
          > This is tricky as the "var" Regular Expression is more than a
          > little ambiguous. You need to firm it up a bit, which will
          > cost in processing time. So for the "var" you could do
          > something rather gross like:
          >
          > "^\\([^nd]\\w*\\|[dn][^ae]\\w*\\|de\\w*\\|na\\w*\\|da\\|ne\\)[ \t]+\\w+[
          > \t]*="
          >

          While I remember....

          The [^nd] is bad as it matches too much, need [a-ce-mo-z] etc.
          But you should get the idea.

          Jon.

          > Which would probably work for most cases, there are a few exections
          > but the RE becomes quite long if you want to catch them all. This
          > would probably do.
          >
          > Infact what you posted is incorrect is it not "\(\w+[ \t]\w+[ \t]*="
          > for the var search ?
          >
          > Jon.
          >
          >
          >
          >
          >
          > __________________________________________________________________________
          >
          > This is an unmoderated list. JASSPA is not responsible for the content of
          > any material posted to this list.
          >
          > To unsubscribe, send a mail message to
          >
          > mailto:jasspa-unsubscribe@yahoogroups.com
          >
          > or visit http://groups.yahoo.com/group/jasspa and
          > modify your account settings manually.
          >
          >
          >
          > Yahoo! Groups Links
          >
          >
          >
          >
          >
          >
        Your message has been successfully submitted and would be delivered to recipients shortly.