(.module: [lux #* [abstract [monad (#+ Monad do)]] [control [pipe (#+ do>)] ["." try (#+ Try)] [parser ["" code]] [security ["!" capability]]] [data [binary (#+ Binary)] ["." text [encoding ["." utf8]]]] [meta ["." location]] [tool [compiler [language [lux ["." syntax]]]]] [world ["." file]]] ["." // #_ ["#" profile (#+ Profile)] ["#." action (#+ Action)] ["#." project (#+ Project)] ["#." parser]]) (def: (parse_lux source_code) (-> Text (Try Code)) (let [parse (syntax.parse "" syntax.no_aliases (text.size source_code))] (case (parse [location.dummy 0 source_code]) (#.Left [_ error]) (#try.Failure error) (#.Right [_ lux_code]) (#try.Success lux_code)))) (def: parse_project (-> Binary (Try Project)) (|>> (do> try.monad [(\ utf8.codec decode)] [..parse_lux] [(list) (.run //parser.project)]))) (def: #export (read monad fs profile) (All [!] (-> (Monad !) (file.System !) Text (! (Try Profile)))) (do (try.with monad) [project_file (!.use (\ fs file) //project.file) project_file (!.use (\ project_file content) [])] (\ monad wrap (|> project_file (do> try.monad [..parse_project] [(//project.profile profile)])))))