<html><div style='background-color:'><DIV class=RTE>
<P>Hey,</P>
<P>I have been trying to program a simple Haskell program that allows me to input a list of Java files and their dependencies (i.e. other files which they rely upon) and have come across some very stubborn problems.</P>
<P>> semiColon :: Char -> Bool<BR>> semiColon ':' = True<BR>> semiColon _ = False</P>
<P>> getFDepend :: String -> String<BR>> getFDepend file = reverse(stripEX(reverse(fst(break semiColon file))))</P>
<P>> getDepends :: String -> [String]<BR>> getDepends depend = words(stripEX(snd(break semiColon depend)))</P>
<P>> getArray :: [String] -> [File]<BR>>getArray [a]<BR>> | length[a] == 1 = [parseFile (head[a])]<BR>> | otherwise = [parseFile (head[a])] && (getArray (tail[a]))</P>
<P>> -- WRITE parseDependency, 12 marks</P>
<P>> parseDependency :: String -> Dependency<BR>> parseDependency ds = (Dependency (parseFile(getFDepend(ds))) [getArray(getDepends ds)])</P>
<P> </P>
<P><BR>> fullStop :: Char -> Bool<BR>> fullStop '.' = True<BR>> fullStop _ = False</P>
<P>Removes leading whitespace and fullstops</P>
<P>> stripEX :: String -> String<BR>> stripEX [] = []<BR>> stripEX (a:ab)<BR>> | isSpace a = stripEX ab<BR>> | fullStop a = stripEX ab<BR>> | semiColon a = stripEX ab<BR>> | otherwise = (a:ab)</P>
<P>Gets the filename</P>
<P>> getFirst :: String -> String<BR>> getFirst filename = fst (break fullStop filename)</P>
<P>Gets the unformated extension</P>
<P>> formatLast :: String -> String<BR>> formatLast ext = snd (break fullStop ext)</P>
<P>Formats the extension</P>
<P>> getLast :: String -> String<BR>> getLast ext = stripEX(reverse (stripEX (reverse (formatLast(ext)))))</P>
<P>> parseFile :: String -> File<BR>> parseFile name = File { basename = (getFirst(name)), ext = classifyExtension(getLast(name)) }<BR></P>
<P>For some reason my getArray function keeps kicking up a program. I am unsure if I have done this correctly. What I was aiming to do was take a List of strings ("A.java", "B.java") and create a File type for each of them, then add this to an array which would be returned at the end.</P>
<P>Anyone know a better method or what is wrong?</P>
<P>-Mike</P></DIV></div></html>