make for library browser

This commit is contained in:
aarne
2012-05-30 08:42:11 +00:00
parent 7e467eb431
commit 12e142724b
2 changed files with 2 additions and 0 deletions

View File

@@ -1,23 +0,0 @@
import Char
import List
main = interact (unlines . map mkOne . lines)
mkOne line = case words line of
fun : ":" : typ -> mkGF fun (init typ)
_ -> []
mkGF fun typ = unwords $ case typ of
[ty] -> ["lin",fun] ++ ["=","mkTerm"] ++ [quotes fun] ++ [";"]
_ -> ["lin",fun] ++ args ++ ["=","mkTerm",lin] ++ args ++ [";"]
where
cats = filter (/="->") typ
(src,target) = splitAt (length cats - 1) cats
args = [x ++ "_" ++ show n | (x,n) <- zip (map unCap src) [1..]]
lin = quotes ("mk" ++ head target)
unCap = map toLower
quotes s = "\"" ++ s ++ "\""