Commit 2f5e656b authored by Michael Hanus's avatar Michael Hanus
Browse files

Soem refactoring

parent 3dbae13b
......@@ -9,31 +9,18 @@
--- <empty line> -> terminate GUI
--- q -> terminate GUI
---
--- @version June 2011
--- @version October 2015
------------------------------------------------------------------------
import IO
import GUI
import ReadNumeric
import FlatCurry.Show(showCurryId)
import List(isPrefixOf)
import Distribution(getLoadPathForFile)
import FileGoodies
import Distribution(lookupModuleSourceInLoadPath)
import System(getArgs)
import Char(isAlpha,isSpace)
import Maybe(isJust)
---------------------------------------------------------------------
-- add a directory name for a Curry source file by looking up the
-- current load path (CURRYPATH):
findSourceFileInLoadPath :: String -> IO (String)
findSourceFileInLoadPath modname = do
loadpath <- getLoadPathForFile modname
mbfname <- lookupFileInPath (baseName modname) [".lcurry",".curry"] loadpath
maybe (error $ "Curry file for module \""++modname++"\" not found!")
return
mbfname
-- find a function declaration in a program text:
findFunDeclInProgText :: String -> String -> Int
findFunDeclInProgText progtext fname =
......@@ -84,11 +71,14 @@ sourceProgGUI cnt progdefs =
-- start the counter GUI:
startGUI :: String -> IO ()
startGUI prog = do
filename <- findSourceFileInLoadPath prog
contents <- readFile filename
runHandlesControlledGUI ("Module: "++filename)
(sourceProgGUI contents (splitProgDefs contents))
[stdin]
mbsrc <- lookupModuleSourceInLoadPath prog
case mbsrc of
Nothing -> error $ "Curry file for module \""++prog++"\" not found!"
Just (_,filename) -> do
contents <- readFile filename
runHandlesControlledGUI ("Module: "++filename)
(sourceProgGUI contents (splitProgDefs contents))
[stdin]
main :: IO ()
main = do
......@@ -140,9 +130,3 @@ isCommentLine :: String -> Bool
isCommentLine l = take 2 (dropWhile isSpace l) == "--"
----------------------------------------------------------------------------
m :: String -> IO ()
m prog = do
filename <- findSourceFileInLoadPath prog
contents <- readFile filename
print $ splitProgDefs contents
......@@ -51,7 +51,7 @@ showMake mainmod sourcefiles =
-- add a directory name for a Curry source file by looking up the
-- current load path (CURRYPATH):
findSourceFileInLoadPath modname = do
loadpath <- getLoadPathForFile modname
loadpath <- getLoadPathForModule modname
mbfname <- lookupFileInPath (baseName modname) [".lcurry",".curry"] loadpath
maybe (error ("Curry file for module \""++modname++"\" not found!"))
(return . dropLocal)
......
......@@ -24,7 +24,7 @@ import System(getArgs,getEnviron,system)
import Directory
import FileGoodies
import Sort(mergeSort,leqString)
import Distribution(getLoadPathForFile,stripCurrySuffix,modNameToPath
import Distribution(stripCurrySuffix,modNameToPath
,lookupModuleSourceInLoadPath)
main = do
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment