Even Wiik Thomassen committed 9af218d

Added some examples.

  • Participants
  • Parent commits 4f9b2da

Comments (0)

Files changed (5)

File appendices.tex

+\chapter{External Core and JSCore}

File code/lambda.hcj

+{"%module": ["main:Main", ""], "tdef": [],
+ "vdefg": [{"%rec": [{"qvar": "repeat'r9Y",
+                      "ty": {"bty": {"bty": {"qtycon": ["ghc-prim:GHC.Prim", "(->)"]},
+                                     "aty": {"qtycon": ["ghc-prim:GHC.Types", "Int"]}},
+                             "aty": {"bty": {"bty": {"qtycon": ["ghc-prim:GHC.Prim", "(->)"]},
+                                             "aty": {"qtycon": ["ghc-prim:GHC.Types", "Int"]}},
+                                     "aty": {"bty": {"qtycon": ["ghc-prim:GHC.Types", "[]"]},
+                                             "aty": {"qtycon": ["ghc-prim:GHC.Types", "Int"]}}}},
+                      "exp": {"lambda": {"vbind": {"var": "dsdrE", "ty": {"qtycon": ["ghc-prim:GHC.Types", "Int"]}}},
+                              "exp": {"lambda": {"vbind": {"var": "ds1drF", "ty": {"qtycon": ["ghc-prim:GHC.Types", "Int"]}}},
+                                      "exp": {"%case": {"bty": {"qtycon": ["ghc-prim:GHC.Types", "[]"]},
+                                                        "aty": {"qtycon": ["ghc-prim:GHC.Types", "Int"]}},
+                                              "exp": {"qvar": "dsdrE"},
+                                              "%of": {"var": "wildX6", "ty": {"qtycon": ["ghc-prim:GHC.Types", "Int"]}},
+                                              "alt": [{"qdcon": ["ghc-prim:GHC.Types", "I#"], "tyvar": [],
+                                                       "vbind": [{"var": "ds2drG",
+                                                                  "ty": {"qtycon": ["ghc-prim:GHC.Prim", "Int#"]}}],
+                                                       "exp": {"%case": {"bty": {"qtycon": ["ghc-prim:GHC.Types", "[]"]},
+                                                                         "aty": {"qtycon": ["ghc-prim:GHC.Types", "Int"]}},
+                                                               "exp": {"qvar": "ds2drG"},
+                                                               "%of": {"var": "ds3XrM",
+                                                                       "ty": {"qtycon": ["ghc-prim:GHC.Prim", "Int#"]}},
+                                                               "alt": [{"%_": {"aexp": {"aexp": {"aexp": {"qdcon": ["ghc-prim:GHC.Types",
+                                                                                                                    ":"]},
+                                                                                                 "args": {"aty": {"qtycon": ["ghc-prim:GHC.Types",
+                                                                                                                             "Int"]}}},
+                                                                                        "args": {"aexp": {"qvar": "ds1drF"}}},
+                                                                               "args": {"aexp": {"aexp": {"aexp": {"qvar": "repeat'r9Y"},
+                                                                                                          "args": {"aexp": {"aexp": {"aexp": {"aexp": {"aexp": {"qvar": ["base:GHC.Num",
+                                                                                                                                                                         "-"]},
+                                                                                                                                                       "args": {"aty": {"qtycon": ["ghc-prim:GHC.Types",
+                                                                                                                                                                                   "Int"]}}},
+                                                                                                                                              "args": {"aexp": {"qvar": ["base:GHC.Num",
+                                                                                                                                                                         "$fNumInt"]}}},
+                                                                                                                                     "args": {"aexp": {"qvar": "wildX6"}}},
+                                                                                                                            "args": {"aexp": {"aexp": {"qdcon": ["ghc-prim:GHC.Types",
+                                                                                                                                                                 "I#"]},
+                                                                                                                                              "args": {"aexp": {"lit": {"int": 1},
+                                                                                                                                                                "ty": {"qtycon": ["ghc-prim:GHC.Prim",
+                                                                                                                                                                                  "Int#"]}}}}}}}},
+                                                                                                 "args": {"aexp": {"qvar": "ds1drF"}}}}}},
+                                                                       {"lit": {"lit": {"int": 0},
+                                                                                "ty": {"qtycon": ["ghc-prim:GHC.Prim", "Int#"]}},
+                                                                        "exp": {"aexp": {"qdcon": ["ghc-prim:GHC.Types", "[]"]},
+                                                                                "args": {"aty": {"qtycon": ["ghc-prim:GHC.Types",
+                                                                                                            "Int"]}}}}]}}]}}}}]},
+           {"qvar": ["main:Main", "main"],
+            "ty": {"bty": {"qtycon": ["ghc-prim:GHC.Types", "IO"]}, "aty": {"qtycon": ["ghc-prim:GHC.Tuple", "()"]}},
+            "exp": {"aexp": {"aexp": {"aexp": {"qvar": ["base:System.IO", "print"]},
+                                      "args": {"aty": {"qtycon": ["ghc-prim:GHC.Types", "Int"]}}},
+                             "args": {"aexp": {"qvar": ["base:GHC.Show", "$fShowInt"]}}},
+                    "args": {"aexp": {"aexp": {"aexp": {"qvar": ["base:GHC.List", "length"]},
+                                               "args": {"aty": {"qtycon": ["ghc-prim:GHC.Types", "Int"]}}},
+                                      "args": {"aexp": {"aexp": {"aexp": {"qvar": "repeat'r9Y"},
+                                                                 "args": {"aexp": {"aexp": {"qdcon": ["ghc-prim:GHC.Types",
+                                                                                                      "I#"]},
+                                                                                   "args": {"aexp": {"lit": {"int": 10},
+                                                                                                     "ty": {"qtycon": ["ghc-prim:GHC.Prim",
+                                                                                                                       "Int#"]}}}}}},
+                                                        "args": {"aexp": {"aexp": {"qdcon": ["ghc-prim:GHC.Types", "I#"]},
+                                                                          "args": {"aexp": {"lit": {"int": 5},
+                                                                                            "ty": {"qtycon": ["ghc-prim:GHC.Prim",
+                                                                                                              "Int#"]}}}}}}}}}}},
+           {"qvar": ["main::Main", "main"],
+            "ty": {"bty": {"qtycon": ["ghc-prim:GHC.Types", "IO"]}, "aty": {"qtycon": ["ghc-prim:GHC.Tuple", "()"]}},
+            "exp": {"aexp": {"aexp": {"qvar": ["base:GHC.TopHandler", "runMainIO"]},
+                             "args": {"aty": {"qtycon": ["ghc-prim:GHC.Tuple", "()"]}}},
+                    "args": {"aexp": {"qvar": ["main:Main", "main"]}}}}]}

File code/lambda.hcr

+%module main:Main
+  %rec
+  {repeat'r9Y :: ghc-prim:GHC.Types.Int ->
+                  ghc-prim:GHC.Types.Int ->
+                  (ghc-prim:GHC.Types.[] ghc-prim:GHC.Types.Int) =
+     \ (dsdrE::ghc-prim:GHC.Types.Int)
+       (ds1drF::ghc-prim:GHC.Types.Int) ->
+         %case ((ghc-prim:GHC.Types.[] ghc-prim:GHC.Types.Int)) dsdrE
+         %of (wildX6::ghc-prim:GHC.Types.Int)
+           {ghc-prim:GHC.Types.I# (ds2drG::ghc-prim:GHC.Prim.Int#) ->
+              %case ((ghc-prim:GHC.Types.[] ghc-prim:GHC.Types.Int)) ds2drG
+              %of (ds3XrM::ghc-prim:GHC.Prim.Int#)
+                {%_ ->
+                   ghc-prim:GHC.Types.: @ ghc-prim:GHC.Types.Int ds1drF
+                   (repeat'r9Y
+                    (base:GHC.Num.- @ ghc-prim:GHC.Types.Int
+                     base:GHC.Num.$fNumInt wildX6
+                     (ghc-prim:GHC.Types.I# (1::ghc-prim:GHC.Prim.Int#)))
+                    ds1drF);
+                 (0::ghc-prim:GHC.Prim.Int#) ->
+                   ghc-prim:GHC.Types.[] @ ghc-prim:GHC.Types.Int}}};
+  main:Main.main :: (ghc-prim:GHC.Types.IO
+                     ghc-prim:GHC.Tuple.()) =
+    base:System.IO.print @ ghc-prim:GHC.Types.Int
+    base:GHC.Show.$fShowInt
+    (base:GHC.List.length @ ghc-prim:GHC.Types.Int
+     (repeat'r9Y
+      (ghc-prim:GHC.Types.I# (10::ghc-prim:GHC.Prim.Int#))
+      (ghc-prim:GHC.Types.I# (5::ghc-prim:GHC.Prim.Int#))));
+  main::Main.main :: (ghc-prim:GHC.Types.IO
+                       ghc-prim:GHC.Tuple.()) =
+    base:GHC.TopHandler.runMainIO @ ghc-prim:GHC.Tuple.()
+    main:Main.main;

File code/lambda.hs

+main = print (length (repeat' 10 5))
+repeat' :: Int -> Int -> [Int]
+repeat' 0 _ = []
+repeat' n x = x : repeat' (n - 1) x
 of external Core that was last updated for \gls{ghc} version 6.10.
 The time period between these two versions are about four years. In these four
 years Core has seen significant work, while external Core has only received
-minor improvements.
-TODO: Describe what doesn't work, and some of the problems this create.
+minor improvements. For example, external Core does not support \gls{gadt},
+type families, integer literals, and left and right coercion.
 It is not only external Core that causes problems for PyHaskell. The
 \textit{extcore} package has been abandoned, and was last updated  over a year
 on Haskell's online library: \url{}}, it was last run on \gls{ghc}
 version 7.0.
 Therefor there are a few things external Core supports, that extcore does not,
-for example TODO. 
+for example \todo{TODO}.
 The extcore package also has some unwanted behavior, for example it splits
 lambda-statements into several where each one has only one variable.
-TODO: Show this.
 The \mycode{core2js}-program in \citet{skrede}'s pipeline also has some further
 issues, such as the \gls{json}-encoding of external Core is verbose. It is more
 verbose than what is required by \gls{json}.
 TODO: Show this.
 Improvements to \mycode{core2js} would not be beneficial until the problems
 In addition to the issues mentioned, the external Core approach has several
 limitations that must be also be solved before PyHaskell can fully support the
-Haskell language, Prelude, and test suite.
+Haskell language, Prelude, and \gls{ghc}'s test suite.
 \citet{hudak} note that Haskell has gained ``dozens of language extensions
 (notably in the type system)''~\cite[p.~29]{hudak}. In the newer versions of
+While external Core support a large number of Haskell language features, it
+does not support the Haskell Prelude. Therefor we can not possibly hope to
+support \gls{ghc}'s test suite nor the nofib benchmark suite. Not atleast
+without first using one of the solutions mentioned, and even then it would not
+be certain that we would be able to support these things.
 ``Over the fifteen years of its life so far, \gls{ghc} has grown a huge number
 of features (\ldots) This makes \gls{ghc} a dauntingly complex beast to
 understand and modify and, mainly for that reason, development of the core