aboutsummaryrefslogtreecommitdiffstats
path: root/autotypes/app/Main.hs
blob: d9fa7f44b100f3ab9483151ea8dff9b95c139abd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
module Main where

import AutoTypes.Unify as U
import Data.Aeson (Value, decodeFileStrict', encode)
import qualified Data.ByteString.Lazy as B
import System.Environment (getArgs)
import System.FilePath (takeFileName)

main :: IO ()
main = do
  filePaths <- getArgs
  types <-
    mapM
      ( \filePath -> do
          Just value <- decodeFileStrict' filePath
          pure (U.fromJson value)
      )
      filePaths
  B.putStr
    ( encode
        ( head
            ( foldr1
                (\ls rs -> (concat [unify1 l r | l <- ls, r <- rs]))
                (map (: []) types)
            )
        )
    )