packages feed

she-0.0: src/Main.lhs

> module Main where

> import System.Environment
> import System.FilePath
> import Data.Char
> import Data.Traversable
> import Data.Foldable

> import HaLay
> import Imports
> import Aspect
> import Patsy
> import TypesToKinds

> sheGoes :: [[Tok]] -> [[Tok]] -> ([[Tok]], [[Tok]])
> sheGoes hersi0 hs0 =
>   let nl = dental hs0
>       (higs0, hersi1) = foldMap higgle hersi0
>       (higs1, hs1) = foldMap higgle hs0
>       higs = higs0 ++ higs1
>       herso0 = higs >>= higOut
>       hs2 = piggle higs hs1
>       ((ps0, herso1), _) = traverse getPatsy hersi1
>       ((ps1, herso2), hs3) = traverse getPatsy hs2
>       hs4 = case prepare (ps0 ++ ps1) of
>               Nothing -> hs3
>               Just ps -> map (processes ps) hs3
>       hs5 = typesToKinds hs4 ++ redent nl (hs4 >>= dataGrok)
>   in  (herso0 ++ [[NL]] ++ herso1 ++ [[NL]] ++ herso2, hs5)

> hsAndHers :: String -> IO (String, String)
> hsAndHers s = do
>   let ihs = ready s
>   pcs <- storySoFar ihs
>   let (hers, hs) = sheGoes pcs ihs
>   return (tokssOut hs, tokssOut hers)

> main :: IO ()
> main = do
>   x : y : z : _ <- getArgs
>   let x' = replaceExtension x ".hers"
>   putStrLn x
>   putStrLn y
>   putStrLn z
>   f <- readFile y
>   (f', h) <- hsAndHers f
>   writeFile x' h
>   writeFile z f'