From ec0ea18486ed2569808f2e511ecac52f812300b0 Mon Sep 17 00:00:00 2001 From: Alexander Foremny Date: Tue, 28 May 2024 22:04:34 +0200 Subject: init --- autotypes/src/AutoTypes.hs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 autotypes/src/AutoTypes.hs (limited to 'autotypes/src/AutoTypes.hs') diff --git a/autotypes/src/AutoTypes.hs b/autotypes/src/AutoTypes.hs new file mode 100644 index 0000000..c5a43d1 --- /dev/null +++ b/autotypes/src/AutoTypes.hs @@ -0,0 +1,25 @@ +module AutoTypes + ( autoTypes, + autoTypes', + ) +where + +import Debug.Trace +import qualified AutoTypes.Unify as U +import Data.Aeson (Value, decodeFileStrict', encode) +import Data.Maybe (fromJust) +import System.Environment (getArgs) +import System.FilePath (takeFileName) + +autoTypes :: FilePath -> [FilePath] -> IO U.T +autoTypes fp fps = autoTypes' <$> go fp <*> mapM go (fp : fps) + where go = fmap fromJust . decodeFileStrict' + +autoTypes' :: Value -> [Value] -> U.T +autoTypes' t' ts' = + let types = map U.fromJson (Debug.Trace.traceShowId (t' : ts')) + in head + ( foldr1 + (\ls rs -> (concat [U.unify1 l r | l <- ls, r <- rs])) + (map (: []) types) + ) -- cgit v1.2.3