mirror of
https://github.com/Avi-D-coder/implicit-hie.git
synced 2024-11-30 00:33:29 +03:00
27 lines
832 B
Haskell
27 lines
832 B
Haskell
{-# LANGUAGE MultiWayIf #-}
|
|
|
|
module Main where
|
|
|
|
import Control.Monad
|
|
import Data.Attoparsec.Text
|
|
import qualified Data.Text as T
|
|
import qualified Data.Text.IO as T
|
|
import Hie.Cabal.Parser
|
|
import Hie.Yaml
|
|
import System.Directory
|
|
import System.FilePath.Posix
|
|
|
|
main :: IO ()
|
|
main = do
|
|
files <- listDirectory =<< getCurrentDirectory
|
|
let path = filter ((".cabal" ==) . takeExtension) files
|
|
sOrC =
|
|
if | any ((".stack-work" ==) . takeFileName) files -> stackHieYaml
|
|
| any (("dist-newstyle" ==) . takeFileName) files -> cabalHieYaml
|
|
| otherwise -> stackHieYaml
|
|
when (null path) $ error "No .cabal file found!\n You may need to run stack build."
|
|
file <- T.readFile $ head path
|
|
case parseOnly parsePackage file of
|
|
Right r -> T.putStr $ sOrC r
|
|
_ -> error "Could not parse *.cabal file"
|