@@ -7,9 +7,13 @@ import Data.ProtoLens qualified as Pb
77import Data.ProtoLens.TextFormat qualified as PbText
88import Data.Text.Lazy qualified as Text
99import Data.Text.Lazy.IO qualified as Text
10- import LambdaBuffers.Compiler.ProtoCompat (FromProtoErr (NamingError , ProtoError ), IsMessage (fromProto , toProto ))
10+ import LambdaBuffers.Compiler.KindCheck (check )
11+ import LambdaBuffers.Compiler.ProtoCompat (
12+ FromProtoErr (NamingError , ProtoError ),
13+ IsMessage (fromProto , toProto ),
14+ )
1115import LambdaBuffers.Compiler.ProtoCompat.Types qualified as ProtoCompat
12- import Proto.Compiler (CompilerInput )
16+ import Proto.Compiler as ProtoLib (CompilerInput , CompilerOutput )
1317import System.FilePath.Lens (extension )
1418
1519data CompileOpts = CompileOpts
@@ -20,6 +24,8 @@ data CompileOpts = CompileOpts
2024
2125makeLenses ''CompileOpts
2226
27+ -- NOTE(cstml) - let's use Katip instead of print.
28+
2329-- | Compile LambdaBuffers modules
2430compile :: CompileOpts -> IO ()
2531compile opts = do
@@ -30,8 +36,8 @@ compile opts = do
3036 ProtoError pe -> print $ " Encountered a proto error " <> show pe
3137 Right compIn' -> do
3238 print @ String " Successfully processed the CompilerInput"
33- writeCompilerOutput (opts ^. output) (toProto compIn')
34-
39+ let result = check compIn'
40+ writeCompilerOutput (opts ^. output) (toProto result)
3541 return ()
3642
3743readCompilerInput :: FilePath -> IO CompilerInput
@@ -46,11 +52,10 @@ readCompilerInput fp = do
4652 return $ PbText. readMessageOrDie content
4753 _ -> error $ " Unknown CompilerInput format " <> ext
4854
49- -- FIXME(bladyjoker): Do this properly when you figure out what the CompilerOutput is.
50- writeCompilerOutput :: FilePath -> CompilerInput -> IO ()
51- writeCompilerOutput fp co = do
55+ writeCompilerOutput :: FilePath -> ProtoLib. CompilerOutput -> IO ()
56+ writeCompilerOutput fp cr = do
5257 let ext = fp ^. extension
5358 case ext of
54- " .pb" -> BS. writeFile fp (Pb. encodeMessage co )
55- " .textproto" -> Text. writeFile fp (Text. pack . show $ PbText. pprintMessage co )
59+ " .pb" -> BS. writeFile fp (Pb. encodeMessage cr )
60+ " .textproto" -> Text. writeFile fp (Text. pack . show $ PbText. pprintMessage cr )
5661 _ -> error $ " Unknown CompilerOutput format " <> ext
0 commit comments