Packages

Erlang code generator for Idris 2

Current section

Files

Jump to
idris2 src Idris.Idris2.Compiler.ES.Javascript.erl
Raw

src/Idris.Idris2.Compiler.ES.Javascript.erl

-module('Idris.Idris2.Compiler.ES.Javascript').
-compile('no_auto_import').
-compile('inline').
-compile({'inline_size',24}).
-export([
'case--compileExpr-2495'/9,
'case--addHeaderAndFooter-2455'/3,
'un--htmlHeader'/0,
'un--htmlFooter'/0,
'un--executeExpr'/4,
'un--compileToJS'/3,
'un--compileLibrary'/6,
'un--compileExpr'/6,
'un--codegenJavascript'/0,
'un--addHeaderAndFooter'/2
]).
'case--compileExpr-2495'(V0, V1, V2, V3, V4, V5, V6, V7, V8) -> case V8 of {'Idris.Prelude.Types.Right', E0} -> (fun (V9) -> case V9 of {'Idris.Builtin.MkUnit'} -> (fun () -> fun (V10) -> {'Idris.Prelude.Types.Right', {'Idris.Prelude.Types.Just', V7}} end end()); _ -> ('erlang':'throw'("Error: Unreachable branch")) end end(E0)); {'Idris.Prelude.Types.Left', E1} -> (fun (V11) -> fun (V12) -> ('Idris.Idris2.Core.Core':'dn--un--throw_Catchable__Core_Error'('erased', {'Idris.Core.Core.FileErr', V7, V11}, V12)) end end(E1)); _ -> ('erlang':'throw'("Error: Unreachable branch")) end.
'case--addHeaderAndFooter-2455'(V0, V1, V2) -> case V2 of {'Idris.Prelude.Types.Just', E0} -> (fun (V3) -> case V3 of <<"html"/utf8>> -> ('Idris.Idris2.Prelude.Types.Strings':'un--++'(('un--htmlHeader'()), ('Idris.Idris2.Prelude.Types.Strings':'un--++'(V0, ('un--htmlFooter'()))))); _ -> V0 end end(E0)); _ -> V0 end.
'un--htmlHeader'() -> (('Idris.Idris2.Prelude.Interfaces':'un--concat'('erased', 'erased', {'Idris.Builtin.MkPair', {'Idris.Prelude.Interfaces.dn--un--__mkFoldable', fun (V0) -> fun (V1) -> fun (V2) -> fun (V3) -> fun (V4) -> ('Idris.Idris2.Prelude.Types':'dn--un--foldr_Foldable__List'('erased', 'erased', V2, V3, V4)) end end end end end, fun (V5) -> fun (V6) -> fun (V7) -> fun (V8) -> fun (V9) -> ('Idris.Idris2.Prelude.Types':'dn--un--foldl_Foldable__List'('erased', 'erased', V7, V8, V9)) end end end end end}, {'Idris.Prelude.Interfaces.dn--un--__mkMonoid', fun (V10) -> fun (V11) -> ('Idris.Idris2.Prelude.Types':'dn--un--<+>_Semigroup__String'(V10, V11)) end end, ('Idris.Idris2.Prelude.Types':'dn--un--neutral_Monoid__String'())}}))([<<"<html>\x{a}"/utf8>> | [<<" <head>\x{a}"/utf8>> | [<<" <meta charset=\x{27}utf-8\x{27}>\x{a}"/utf8>> | [<<" </head>\x{a}"/utf8>> | [<<" <body>\x{a}"/utf8>> | [<<" <script type=\x{27}text/javascript\x{27}>\x{a}"/utf8>> | []]]]]]])).
'un--htmlFooter'() -> (('Idris.Idris2.Prelude.Interfaces':'un--concat'('erased', 'erased', {'Idris.Builtin.MkPair', {'Idris.Prelude.Interfaces.dn--un--__mkFoldable', fun (V0) -> fun (V1) -> fun (V2) -> fun (V3) -> fun (V4) -> ('Idris.Idris2.Prelude.Types':'dn--un--foldr_Foldable__List'('erased', 'erased', V2, V3, V4)) end end end end end, fun (V5) -> fun (V6) -> fun (V7) -> fun (V8) -> fun (V9) -> ('Idris.Idris2.Prelude.Types':'dn--un--foldl_Foldable__List'('erased', 'erased', V7, V8, V9)) end end end end end}, {'Idris.Prelude.Interfaces.dn--un--__mkMonoid', fun (V10) -> fun (V11) -> ('Idris.Idris2.Prelude.Types':'dn--un--<+>_Semigroup__String'(V10, V11)) end end, ('Idris.Idris2.Prelude.Types':'dn--un--neutral_Monoid__String'())}}))([<<"\x{a} </script>\x{a}"/utf8>> | [<<" </body>\x{a}"/utf8>> | [<<"</html>"/utf8>> | []]]])).
'un--executeExpr'(V0, V1, V2, V3) -> ('Idris.Idris2.Core.Core':'dn--un--throw_Catchable__Core_Error'('erased', {'Idris.Core.Core.InternalError', <<"Javascript backend is only able to compile, use Node instead"/utf8>>}, V3)).
'un--compileToJS'(V0, V1, V2) -> ('Idris.Idris2.Compiler.ES.ES':'un--compileToES'(V0, V1, [<<"browser"/utf8>> | [<<"javascript"/utf8>> | []]], V2)).
'un--compileLibrary'(V0, V1, V2, V3, V4, V5) -> begin (V34 = begin (V33 = (('Idris.Idris2.Prelude.IO':'un--putStrLn'('erased', {'Idris.Prelude.IO.dn--un--__mkHasIO', {'Idris.Prelude.Interfaces.dn--un--__mkMonad', {'Idris.Prelude.Interfaces.dn--un--__mkApplicative', fun (V6) -> fun (V7) -> fun (V8) -> fun (V9) -> fun (V10) -> ('Idris.Idris2.Prelude.IO':'dn--un--map_Functor__IO'('erased', 'erased', V8, V9, V10)) end end end end end, fun (V11) -> fun (V12) -> fun (V13) -> V12 end end end, fun (V14) -> fun (V15) -> fun (V16) -> fun (V17) -> fun (V18) -> begin (V19 = (V16(V18))), begin (V20 = (V17(V18))), (V19(V20)) end end end end end end end}, fun (V21) -> fun (V22) -> fun (V23) -> fun (V24) -> fun (V25) -> begin (V26 = (V23(V25))), ((V24(V26))(V25)) end end end end end end, fun (V27) -> fun (V28) -> fun (V29) -> begin (V30 = (V28(V29))), (V30(V29)) end end end end}, fun (V31) -> fun (V32) -> V32 end end}, <<"Compiling to library is not supported."/utf8>>))(V5))), {'Idris.Prelude.Types.Right', V33} end), case V34 of {'Idris.Prelude.Types.Left', E0} -> (fun (V35) -> {'Idris.Prelude.Types.Left', V35} end(E0)); {'Idris.Prelude.Types.Right', E1} -> (fun (V36) -> {'Idris.Prelude.Types.Right', {'Idris.Prelude.Types.Nothing'}} end(E1)); _ -> ('erlang':'throw'("Error: Unreachable branch")) end end.
'un--compileExpr'(V0, V1, V2, V3, V4, V5) -> begin (V6 = ('un--compileToJS'(V0, V3, V5))), case V6 of {'Idris.Prelude.Types.Left', E0} -> (fun (V7) -> {'Idris.Prelude.Types.Left', V7} end(E0)); {'Idris.Prelude.Types.Right', E1} -> (fun (V8) -> begin (V9 = ('un--addHeaderAndFooter'(V4, V8))), begin (V10 = ('Idris.Idris2.Utils.Path':'un--</>'(V2, V4))), begin (V39 = begin (V38 = (('Idris.Idris2.Erlang.System.File':'un--writeFile'('erased', {'Idris.Prelude.IO.dn--un--__mkHasIO', {'Idris.Prelude.Interfaces.dn--un--__mkMonad', {'Idris.Prelude.Interfaces.dn--un--__mkApplicative', fun (V11) -> fun (V12) -> fun (V13) -> fun (V14) -> fun (V15) -> ('Idris.Idris2.Prelude.IO':'dn--un--map_Functor__IO'('erased', 'erased', V13, V14, V15)) end end end end end, fun (V16) -> fun (V17) -> fun (V18) -> V17 end end end, fun (V19) -> fun (V20) -> fun (V21) -> fun (V22) -> fun (V23) -> begin (V24 = (V21(V23))), begin (V25 = (V22(V23))), (V24(V25)) end end end end end end end}, fun (V26) -> fun (V27) -> fun (V28) -> fun (V29) -> fun (V30) -> begin (V31 = (V28(V30))), ((V29(V31))(V30)) end end end end end end, fun (V32) -> fun (V33) -> fun (V34) -> begin (V35 = (V33(V34))), (V35(V34)) end end end end}, fun (V36) -> fun (V37) -> V37 end end}, V10, V9))(V5))), {'Idris.Prelude.Types.Right', V38} end), case V39 of {'Idris.Prelude.Types.Left', E2} -> (fun (V40) -> {'Idris.Prelude.Types.Left', V40} end(E2)); {'Idris.Prelude.Types.Right', E3} -> (fun (V41) -> case V41 of {'Idris.Prelude.Types.Right', E4} -> (fun (V42) -> case V42 of {'Idris.Builtin.MkUnit'} -> (fun () -> {'Idris.Prelude.Types.Right', {'Idris.Prelude.Types.Just', V10}} end()); _ -> ('erlang':'throw'("Error: Unreachable branch")) end end(E4)); {'Idris.Prelude.Types.Left', E5} -> (fun (V43) -> ('Idris.Idris2.Core.Core':'dn--un--throw_Catchable__Core_Error'('erased', {'Idris.Core.Core.FileErr', V10, V43}, V5)) end(E5)); _ -> ('erlang':'throw'("Error: Unreachable branch")) end end(E3)); _ -> ('erlang':'throw'("Error: Unreachable branch")) end end end end end(E1)); _ -> ('erlang':'throw'("Error: Unreachable branch")) end end.
'un--codegenJavascript'() -> {'Idris.Compiler.Common.MkCG', fun (V0) -> fun (V1) -> fun (V2) -> fun (V3) -> fun (V4) -> fun (V5) -> ('un--compileExpr'(V0, V1, V2, V3, V4, V5)) end end end end end end, fun (V6) -> fun (V7) -> fun (V8) -> fun (V9) -> ('un--executeExpr'(V6, V7, V8, V9)) end end end end, fun (V10) -> fun (V11) -> fun (V12) -> fun (V13) -> fun (V14) -> fun (V15) -> ('un--compileLibrary'(V10, V11, V12, V13, V14, V15)) end end end end end end}.
'un--addHeaderAndFooter'(V0, V1) -> ('case--addHeaderAndFooter-2455'(V1, V0, ('Idris.Idris2.Prelude.Interfaces':'un--<$>'('erased', 'erased', 'erased', fun (V2) -> fun (V3) -> fun (V4) -> fun (V5) -> ('Idris.Idris2.Prelude.Types':'dn--un--map_Functor__Maybe'('erased', 'erased', V4, V5)) end end end end, fun (V6) -> ('Idris.Idris2.Data.Strings':'un--toLower'(V6)) end, ('Idris.Idris2.Utils.Path':'un--extension'(V0)))))).