<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">Thanks, <br>
      <br>
      Found it. <br>
      <br>
      Now I have to find out how I can test if the LogMessage  has the
      text "this is not the right format" in it. <br>
      <br>
      Roelof<br>
      <br>
      <br>
      <br>
      Sumit Sahrawat, Maths & Computing, IIT (BHU) schreef op
      28-2-2015 om 19:49:<br>
    </div>
    <blockquote
cite="mid:CAJbEW8NvZttQTemjyJ2xDnVPWyHusYwuev_9u958gNUhRcsN6A@mail.gmail.com"
      type="cite">
      <div dir="ltr">Don't worry. Keep these points in mind and re-read
        my previous mail.
        <div><br>
        </div>
        <div>Regarding data vs. type constructors.</div>
        <div><br>
        </div>
        <div>1) Leaf :: MessageTree (Leaf is a MessageTree)</div>
        <div>2) MessageTree is a type constructor (takes types and gives
          new types)</div>
        <div>3) Node is a data constructor (takes values and gives a new
          MessageTree)</div>
        <div><br>
        </div>
        <div>Regarding insertion.</div>
        <div><br>
        </div>
        <div>1) The "insert" function takes a message and tree, and
          returns a tree with that message inserted into it</div>
        <div>2) We absolutely have to provide it a tree</div>
        <div>3) If we insert an invalid message in the tree, it does not
          get added. Then we get ..... the same tree back.</div>
        <div><br>
        </div>
        <div>If you still cannot see a problem in your code, ask
          yourself the following:</div>
        <div><br>
        </div>
        1) What type does the output of insert (MessageTree Leaf) have,
        and what type should it have<br>
        2) What happens if we insert an invalid string in a non-empty
        tree (according to your code)
        <div><br>
          <div>Don't forget to re-read the previous mail.</div>
          <div>Hope this drives the point home.</div>
        </div>
      </div>
      <div class="gmail_extra"><br>
        <div class="gmail_quote">On 28 February 2015 at 22:59, Roelof
          Wobben <span dir="ltr"><<a moz-do-not-send="true"
              href="mailto:r.wobben@home.nl" target="_blank">r.wobben@home.nl</a>></span>
          wrote:<br>
          <blockquote class="gmail_quote" style="margin:0 0 0
            .8ex;border-left:1px #ccc solid;padding-left:1ex">
            <div bgcolor="#FFFFFF" text="#000000">
              <div>Sorry, <br>
                <br>
                But I do not understand what you mean. <br>
                <br>
                What I try to do is this <br>
                <br>
                If you have a LogMessage which contains " This is not
                the right format " then the LogMessage is not inserted
                in the tree. <br>
                Every other message are inserted in the tree.<br>
                <br>
                So that is why I make a MessageTree with only one Leaf.
                <br>
                <br>
                Roelof<br>
                <br>
                <br>
                <br>
                Sumit Sahrawat, Maths & Computing, IIT (BHU) schreef
                op 28-2-2015 om 16:08:<br>
              </div>
              <div>
                <div class="h5">
                  <blockquote type="cite">
                    <div dir="ltr">You're missing an argument to insert,
                      assuming that it is indeed there, consider this:
                      <div><br>
                      </div>
                      <div><font face="monospace, monospace">    insert
                          msg tree = tree'</font></div>
                      <div><span style="font-family:monospace,monospace"> 
                              where tree' = undefined</span></div>
                      <div><font face="monospace, monospace">    -- Take
                          a LogMessage (msg) and a MessageTree (tree)</font></div>
                      <div><font face="monospace, monospace">    -- and
                          return a new MessageTree (tree')</font></div>
                      <div><font face="monospace, monospace"><br>
                        </font></div>
                      Therefore, the result of insert in your case, i.e.
                      "MessageTree Leaf" should be of type MessageTree.<br>
                      And thus, we get
                      <div><font face="monospace, monospace"><br>
                        </font></div>
                      <div><font face="monospace, monospace">   
                          MessageTree Leaf :: MessageTree</font></div>
                      <div><font face="monospace, monospace">    --
                          Takes a (Leaf :: LogMessage) and produces a
                          MessageTree</font></div>
                      <div><font face="monospace, monospace"><br>
                        </font></div>
                      which implies,
                      <div><font face="monospace, monospace"><br>
                        </font></div>
                      <div><font face="monospace, monospace">   
                          MessageTree :: LogMessage -> MessageTree</font></div>
                      <div><font face="monospace, monospace">    -- A
                          Data constructor</font></div>
                      <div><font face="monospace, monospace"><br>
                        </font></div>
                      Obviously no such data constructor exists. A data
                      constructor of this type would exist only if you
                      wrote something like:
                      <div><br>
                      </div>
                      <div><font face="monospace, monospace">    data
                          MessageTree = MessageTree LogMessage</font></div>
                      <div><span style="font-family:monospace,monospace"> 
                                             | ...</span></div>
                      <div><span style="font-family:monospace,monospace"><br>
                        </span></div>
                      which would not make sense.</div>
                    <div class="gmail_extra"><br>
                      <div class="gmail_quote">On 28 February 2015 at
                        19:09, Roelof Wobben <span dir="ltr"><<a
                            moz-do-not-send="true"
                            href="mailto:r.wobben@home.nl"
                            target="_blank">r.wobben@home.nl</a>></span>
                        wrote:<br>
                        <blockquote class="gmail_quote" style="margin:0
                          0 0 .8ex;border-left:1px #ccc
                          solid;padding-left:1ex">
                          <div bgcolor="#FFFFFF" text="#000000">
                            <div>I tried this : <br>
                              <span> <br>
                                insert :: LogMessage -> MessageTree
                                -> MessageTree<br>
                              </span> insert s = <br>
                                 case words s of <br>
                                     (_:_: "This is not the right
                              format") -> MessageTree Leaf <br>
                                    
                              _                                    
                              -> MessageTree Node LogMessage Leaf <br>
                                  <br>
                              <br>
                              But I see this errormessages which I do
                              not understand : <br>
                              <br>
                              <br>
                              <div>
                                <div>src/LogAnalysis.hs@38:49-38:60 </div>
                                <div><span>Not in scope: data
                                    constructor </span>
                                  <div style="font-size:14px"><span>MessageTree</span></div>
                                </div>
                              </div>
                              <div>
                                <div>src/LogAnalysis.hs@39:49-39:60 </div>
                                <div><span>Not in scope: data
                                    constructor </span>
                                  <div style="font-size:14px"><span>MessageTree<br>
                                      <br>
                                    </span></div>
                                </div>
                              </div>
                              <br>
                              <br>
                              Mike Meyer schreef op 28-2-2015 om 12:17:<br>
                            </div>
                            <div>
                              <div>
                                <blockquote type="cite">
                                  <div dir="ltr">
                                    <div class="gmail_extra">
                                      <div class="gmail_quote">On Sat,
                                        Feb 28, 2015 at 5:07 AM, Roelof
                                        Wobben <span dir="ltr"><<a
                                            moz-do-not-send="true"
                                            href="mailto:r.wobben@home.nl"
                                            target="_blank">r.wobben@home.nl</a>></span>
                                        wrote:<br>
                                        <blockquote class="gmail_quote"
                                          style="margin:0 0 0
                                          .8ex;border-left:1px #ccc
                                          solid;padding-left:1ex">
                                          <div bgcolor="#FFFFFF"
                                            text="#000000">
                                            <div><br>
                                              That part I understand .<br>
                                              <br>
                                              it's more how I do it here
                                              :<br>
                                              <br>
                                              Lets say I have this : <br>
                                              <br>
                                              data MessageType = Info<br>
                                                               | Warning<br>
                                                               | Error
                                              Int<br>
                                                deriving (Show, Eq)<br>
                                              <br>
                                              type TimeStamp = Int<br>
                                              <br>
                                              data LogMessage =
                                              LogMessage MessageType
                                              TimeStamp String<br>
                                                              | Unknown
                                              String<br>
                                                deriving (Show, Eq)<br>
                                              <br>
                                              data MessageTree = Leaf<br>
                                                               | Node
                                              MessageTree LogMessage
                                              MessageTree<br>
                                                deriving (Show, Eq)<br>
                                              <br>
                                              Now I have to put all the
                                              LogMessages in a binary
                                              tree.<br>
                                              with this signature :
                                              insert :: LogMessage ->
                                              MessageTree ->
                                              MessageTree<br>
                                              <br>
                                              I think I need recursion
                                              here but I still not see
                                              how I can make the
                                              clauses. <br>
                                              Normally you can say
                                              somethig like this  []
                                              -> 0  or  1 ->   but
                                              here it seems to be all
                                              seperate logMessages <br>
                                            </div>
                                          </div>
                                        </blockquote>
                                        <div><br>
                                        </div>
                                        <div>Whether you need recursion
                                          or not depends on where you're
                                          to insert the message. For
                                          instance, you could turn them
                                          into a list with:</div>
                                        <div><br>
                                        </div>
                                        <div>insert message tree = Node
                                          tree message Leaf</div>
                                        <div><br>
                                        </div>
                                        <div>Try drawing a few pictures
                                          of what that produces, and
                                          you'll see why it's probably
                                          not what you want.</div>
                                        <div><br>
                                        </div>
                                        <div>You should be able to tell
                                          by looking at the MessageTree
                                          type that you have two cases:
                                          one where you're passed
                                          something matching a Node, and
                                          one where you're passed
                                          something that's just a Leaf.
                                          The latter can't be recursive,
                                          so it's going to terminate any
                                          recursion. Following the
                                          advice given to you for the
                                          Hanoi problem, try writing it
                                          first.</div>
                                        <div><br>
                                        </div>
                                        <div>Then all you have to do is
                                          figure out how to handle the
                                          case where you're given a Node
                                          instead of a Leaf.  Figuring
                                          out where in the MessageTree
                                          you want to insert the
                                          Logmessage will probably be
                                          required to do that.<br>
                                        </div>
                                      </div>
                                    </div>
                                  </div>
                                </blockquote>
                                <br>
                              </div>
                            </div>
                          </div>
                          <br>
_______________________________________________<br>
                          Haskell-Cafe mailing list<br>
                          <a moz-do-not-send="true"
                            href="mailto:Haskell-Cafe@haskell.org"
                            target="_blank">Haskell-Cafe@haskell.org</a><br>
                          <a moz-do-not-send="true"
                            href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe"
                            target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br>
                          <br>
                        </blockquote>
                      </div>
                      <br>
                      <br clear="all">
                      <div><br>
                      </div>
                      -- <br>
                      <div>
                        <div dir="ltr">
                          <div>
                            <div dir="ltr">
                              <div dir="ltr">
                                <div>Regards</div>
                                <div dir="ltr">
                                  <div><br>
                                  </div>
                                  <div>Sumit Sahrawat</div>
                                </div>
                              </div>
                            </div>
                          </div>
                        </div>
                      </div>
                    </div>
                  </blockquote>
                  <br>
                </div>
              </div>
            </div>
            <br>
            _______________________________________________<br>
            Haskell-Cafe mailing list<br>
            <a moz-do-not-send="true"
              href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
            <a moz-do-not-send="true"
              href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe"
              target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br>
            <br>
          </blockquote>
        </div>
        <br>
        <br clear="all">
        <div><br>
        </div>
        -- <br>
        <div class="gmail_signature">
          <div dir="ltr">
            <div>
              <div dir="ltr">
                <div dir="ltr">
                  <div>Regards</div>
                  <div dir="ltr">
                    <div><br>
                    </div>
                    <div>Sumit Sahrawat</div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </blockquote>
    <br>
  </body>
</html>