packages feed

hmeap-0.6: Help/parse.hs

import Control.Monad
import Data.List
import qualified Sound.Analysis.Meapsoft as M
import System.Environment
import System.FilePath
import System.IO

replace :: Eq a => a -> a -> [a] -> [a]
replace _ _ [] = []
replace a b (x:xs) | x == a = b : replace a b xs
                   | otherwise = x : replace a b xs

main :: IO ()
main = do
  a <- getArgs
  unless (length a == 1) (error "analysis-file")
  let [fn] = a
      vn = replace '-' '_' (dropExtensions (takeFileName fn))
  fs <- M.read_file fn
  putStrLn ("-- " ++ fn)
  putStrLn "import Sound.Analysis.Meapsoft"
  putStrLn (vn ++ " :: [Frame]")
  putStrLn (vn ++ " = " ++ show fs)