<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>
      This works  : <br>
      <br>
      -- | Main entry point to the application.<br>
      {-# OPTIONS_GHC -Wall #-}<br>
      <br>
      module LogAnalysis where<br>
      <br>
      import Data.Char (isLetter, isDigit)<br>
      <br>
      isValid :: String -> Bool<br>
      isValid s = go (words s)<br>
          where<br>
            go ([a]:b:_) = isLetter a && all isDigit b<br>
            go _         = False<br>
      <br>
          <br>
      -- | The main entry point.<br>
      main :: IO ()<br>
      main = do<br>
          putStrLn $ ( show (isValid "I 656 He trusts to you to set them
      free,"))<br>
      <br>
      <br>
      Now I have to ty to find out how I can check if a has the contents
      of I/W/E and how to make the right output  (Error/Warning/Info 
      22)   " Text" ) <br>
      and then make it work with this datatype : <br>
      <br>
      data LogMessage = LogMessage MessageType TimeStamp String<br>
                      | Unknown String<br>
        deriving (Show, Eq)<br>
      <br>
      Roelof<br>
      <br>
      Konstantine Rybnikov schreef op 23-2-2015 om 18:49:<br>
    </div>
    <blockquote
cite="mid:CAAbahfRR8y0fMf-fzK0HNxkh8OqBA1Q=D==yieF9EXet-4CWqA@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div>
          <div>
            <div>
              <div>As Alex mentioned, isValid returns Bool, while type
                for putStrLn is `String -> IO ()`. So, in order to
                print something of type Bool, you need to first convert
                it to String. For example, via a function `show`:<br>
                <br>
              </div>
              putStrLn (show True)<br>
              <br>
            </div>
            As Alex mentioned, there's a `print` function, which does
            exactly this:<br>
            <br>
          </div>
          print x = putStrLn (show x)<br>
          <br>
        </div>
        You can use it.<br>
      </div>
      <div class="gmail_extra"><br>
        <div class="gmail_quote">On Mon, Feb 23, 2015 at 7:19 PM, 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>And when Im trying this: <br>
                <span class=""> <br>
                  {-# OPTIONS_GHC -Wall #-}<br>
                  <br>
                  module LogAnalysis where<br>
                  <br>
                  import Log;<br>
                  import Data.Char (isLetter, isDigit)<br>
                  <br>
                </span> isValid :: String -> Bool<span class=""><br>
                  isValid s = go (words s)<br>
                      where<br>
                        go ([a]:b:_) = isLetter a && all isDigit
                  b<br>
                        go _         = False<br>
                  <br>
                      <br>
                </span><span class=""> -- | The main entry point.<br>
                  main :: IO ()<br>
                  main = do<br>
                </span>     putStrLn $ isValid "I 4764 He trusts to you
                to set them free,"<span class=""><br>
                  <br>
                  <br>
                  I see this error message : <br>
                  <br>
                </span>
                <div>src/LogAnalysis.hs@19:16-19:67 </div>
                <div><span>Couldn't match type </span>
                  <div style="font-size:14px"><span>Bool</span></div>
                  <span> with </span>
                  <div style="font-size:14px">[<span>Char</span>]</div>
                  <span> Expected type: String Actual type: Bool</span><span
                    title="Click to show/hide extra information"> …</span><span
                    style="display:inline"> In the second argument of
                    ‘($)’, namely ‘isValid "I 4764 He trusts to you to
                    set them free,"’ In a stmt of a 'do' block: putStrLn
                    $ isValid "I 4764 He trusts to you to set them
                    free,"<br>
                    <br>
                    Roelof<br>
                    <br>
                  </span></div>
                <br>
                <br>
                <br>
                <br>
                Roelof Wobben schreef op 23-2-2015 om 17:19:<br>
              </div>
              <div>
                <div class="h5">
                  <blockquote type="cite">
                    <div>I tried it another way more like explained on
                      this page :  <a moz-do-not-send="true"
href="http://www.seas.upenn.edu/%7Ecis194/spring13/lectures/02-ADTs.html"
                        target="_blank">http://www.seas.upenn.edu/~cis194/spring13/lectures/02-ADTs.html</a><br>
                      <br>
                      so I tried this : <br>
                      <br>
                      parseMessage :: [Char] -> [Char]<br>
                      parseMessage s<br>
                      case Errornumber of <br>
                          IsDigit Errornumber  -> "Geldige string"<br>
                          otherwise            -> "Ongeldige string"<br>
                        where<br>
                            Error = s words<br>
                            Errornumber = Error(ErrorNumber _ _ )<br>
                            Errorcode = Error(_ Errorcode _ )<br>
                      <br>
                      but now I cannot use where :( <br>
                      <br>
                      Roelof<br>
                      <br>
                      <br>
                      <br>
                      <br>
                      Roelof Wobben schreef op 23-2-2015 om 16:10:<br>
                    </div>
                    <blockquote type="cite">
                      <div>Oke, <br>
                        <br>
                        Then I make there a mistake,<br>
                        <br>
                        What I try to do is to send the file to
                        parseMessage and let IsValid check if it´s have
                        the right format. <br>
                        <br>
                        Then after the where I try to check if the
                        function isValid returns true or false. <br>
                        <br>
                        Roelof<br>
                        <br>
                        <br>
                        Konstantine Rybnikov schreef op 23-2-2015 om
                        16:03:<br>
                      </div>
                      <blockquote type="cite">
                        <div dir="ltr">
                          <div>
                            <div>
                              <div>Roelof,<br>
                                <br>
                              </div>
                              You defined isValid function in the
                              upper-scope first, and then you defined a
                              symbol (variable) that re-wrote that name
                              to something different (string "Geldige
                              string"). That's why you get an error
                              saying it doesn't expect arguments.<br>
                              <br>
                            </div>
                            My suggestion is to rename second isValid.<br>
                            <br>
                          </div>
                          Good luck.<br>
                        </div>
                        <div class="gmail_extra"><br>
                          <div class="gmail_quote">On Mon, Feb 23, 2015
                            at 4:50 PM, 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>Chaddaï Fouché schreef op 23-2-2015
                                  om 13:20:<br>
                                </div>
                                <span>
                                  <blockquote type="cite">
                                    <div dir="ltr">
                                      <div>Note that Roelof is doing the
                                        CIS 194 Homework <a
                                          moz-do-not-send="true"
                                          href="http://www.seas.upenn.edu/%7Ecis194/fall14/hw/03-ADTs.pdf"
                                          target="_blank">http://www.seas.upenn.edu/~cis194/fall14/hw/03-ADTs.pdf</a>
                                        (the older version of fall2014,
                                        not the one currently running).
                                        This is much clearer than
                                        Roelof's description, and gives
                                        among other information an
                                        algebraic datatype to represent
                                        log messages.<br>
                                        <br>
                                        <br>
                                        -- <br>
                                      </div>
                                      Jedaï<br>
                                    </div>
                                  </blockquote>
                                  <br>
                                </span> Correct and Im trying to do
                                exercise 1 of Week 2,<br>
                                <br>
                                I have tried this solution : <br>
                                <br>
                                -- | Main entry point to the
                                application.<br>
                                {-# OPTIONS_GHC -Wall #-}<br>
                                <br>
                                module LogAnalysis where<br>
                                <br>
                                import Log;<br>
                                import Data.Char (isLetter, isDigit) <br>
                                <br>
                                isValid :: [Char] -> Bool <br>
                                isValid s = go (words s)<br>
                                    where<br>
                                      go ([a]:b:_) = isLetter a
                                && all isDigit b<br>
                                      go _         = False <br>
                                <br>
                                parseMessage :: [Char] -> [Char]<br>
                                parseMessage s = isValid s <br>
                                    where <br>
                                        isValid = "Geldige string"<br>
                                        _       = "Ongeldige string"<br>
                                <br>
                                -- | The main entry point.<br>
                                main :: IO ()<br>
                                main = do<br>
                                    putStrLn $ parseMessage "I 4764 He
                                trusts to you to set them free," <br>
                                <br>
                                <br>
                                but I see this error message : <br>
                                <br>
                                <div>src/LogAnalysis.hs@16:18-16:27 </div>
                                <div><span>Couldn't match expected type
                                    ‘[Char] -> [Char]’ with actual
                                    type </span>
                                  <div style="font-size:14px">[<span>Char</span>]</div>
                                  <span> The function </span>
                                  <div style="font-size:14px"><span>isValid</span></div>
                                  <span> is applied to one argument, but
                                    its type </span>
                                  <div style="font-size:14px">[<span>Char</span>]</div>
                                  <span> has none</span><span
                                    title="Click to show/hide extra
                                    information"> …</span><span
                                    style="display:inline"> In the
                                    expression: isValid s In an equation
                                    for ‘parseMessage’: parseMessage s =
                                    isValid s where isValid = "Geldige
                                    string" _ = "Ongeldige string"<br>
                                    <br>
                                    <br>
                                  </span></div>
                                <br>
                              </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>
                        </div>
                      </blockquote>
                      <br>
                    </blockquote>
                    <br>
                    <br>
                    <fieldset></fieldset>
                    <br>
                    <pre>_______________________________________________
Haskell-Cafe mailing list
<a moz-do-not-send="true" href="mailto:Haskell-Cafe@haskell.org" target="_blank">Haskell-Cafe@haskell.org</a>
<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>
</pre>
                  </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>
      </div>
    </blockquote>
    <br>
  </body>
</html>