Visitar URL original
Formatting: Indent applications by ocharles · Pull Request #1167 · dhall-lang/dhall-haskell · GitHub
Skip to content

Formatting: Indent applications - #1167

Merged
mergify[bot] merged 1 commit into
dhall-lang:masterfrom
circuithub:indent-applications
Jul 29, 2019
Merged

mergify[bot] merged 1 commit into
dhall-lang:masterfrom
circuithub:indent-applications

Conversation

@ocharles

Copy link
Copy Markdown
Member

Fixes #515.

@ocharles
ocharles requested a review from Gabriella439 July 29, 2019 13:24
@ocharles

Copy link
Copy Markdown
Member Author

Here is the difference on Prelude:

diff --git a/Prelude/JSON/object b/Prelude/JSON/object
index 8da7b09..516c9b2 100644
--- a/Prelude/JSON/object
+++ b/Prelude/JSON/object
@@ -45,13 +45,13 @@ let object
             }
           )
       → json.object
-        ( List/map
-          { mapKey : Text, mapValue : JSON@1 }
-          { mapKey : Text, mapValue : JSON }
-          (   λ(kv : { mapKey : Text, mapValue : JSON@1 })
-            → { mapKey = kv.mapKey, mapValue = kv.mapValue JSON json }
+          ( List/map
+              { mapKey : Text, mapValue : JSON@1 }
+              { mapKey : Text, mapValue : JSON }
+              (   λ(kv : { mapKey : Text, mapValue : JSON@1 })
+                → { mapKey = kv.mapKey, mapValue = kv.mapValue JSON json }
+              )
+              x
           )
-          x
-        )
 
 in  object
diff --git a/Prelude/JSON/render b/Prelude/JSON/render
index b020b23..4f138e5 100644
--- a/Prelude/JSON/render
+++ b/Prelude/JSON/render
@@ -35,32 +35,32 @@ let render
     : JSON → Text
     =   λ(j : JSON)
       → j
-        Text
-        { string =
-            λ(x : Text) → Text/show x
-        , number =
-            λ(x : Double) → Double/show x
-        , object =
-              λ(x : List { mapKey : Text, mapValue : Text })
-            → let body =
-                    Text/concatMapSep
-                    ","
-                    { mapKey : Text, mapValue : Text }
-                    (   λ(e : { mapKey : Text, mapValue : Text })
-                      → " ${Text/show e.mapKey}: ${e.mapValue}"
-                    )
-                    x
-              
-              in  "{${body} }"
-        , array =
-              λ(x : List Text)
-            → let body = Text/concatMapSep "," Text (λ(y : Text) → " ${y}") x
-              
-              in  "[${body} ]"
-        , bool =
-            λ(x : Bool) → if x then "true" else "false"
-        , null =
-            "null"
-        }
+          Text
+          { string =
+              λ(x : Text) → Text/show x
+          , number =
+              λ(x : Double) → Double/show x
+          , object =
+                λ(x : List { mapKey : Text, mapValue : Text })
+              → let body =
+                      Text/concatMapSep
+                        ","
+                        { mapKey : Text, mapValue : Text }
+                        (   λ(e : { mapKey : Text, mapValue : Text })
+                          → " ${Text/show e.mapKey}: ${e.mapValue}"
+                        )
+                        x
+                
+                in  "{${body} }"
+          , array =
+                λ(x : List Text)
+              → let body = Text/concatMapSep "," Text (λ(y : Text) → " ${y}") x
+                
+                in  "[${body} ]"
+          , bool =
+              λ(x : Bool) → if x then "true" else "false"
+          , null =
+              "null"
+          }
 
 in  render
diff --git a/Prelude/List/concat b/Prelude/List/concat
index 604e7b5..0ae35a0 100644
--- a/Prelude/List/concat
+++ b/Prelude/List/concat
@@ -27,16 +27,16 @@ let concat
     =   λ(a : Type)
       → λ(xss : List (List a))
       → List/build
-        a
-        (   λ(list : Type)
-          → λ(cons : a → list → list)
-          → λ(nil : list)
-          → List/fold
-            (List a)
-            xss
-            list
-            (λ(xs : List a) → λ(ys : list) → List/fold a xs list cons ys)
-            nil
-        )
+          a
+          (   λ(list : Type)
+            → λ(cons : a → list → list)
+            → λ(nil : list)
+            → List/fold
+                (List a)
+                xss
+                list
+                (λ(xs : List a) → λ(ys : list) → List/fold a xs list cons ys)
+                nil
+          )
 
 in  concat
diff --git a/Prelude/List/concatMap b/Prelude/List/concatMap
index 2cde97e..489a277 100644
--- a/Prelude/List/concatMap
+++ b/Prelude/List/concatMap
@@ -19,10 +19,10 @@ let concatMap
       → λ(f : a → List b)
       → λ(xs : List a)
       → List/build
-        b
-        (   λ(list : Type)
-          → λ(cons : b → list → list)
-          → List/fold a xs list (λ(x : a) → List/fold b (f x) list cons)
-        )
+          b
+          (   λ(list : Type)
+            → λ(cons : b → list → list)
+            → List/fold a xs list (λ(x : a) → List/fold b (f x) list cons)
+          )
 
 in  concatMap
diff --git a/Prelude/List/filter b/Prelude/List/filter
index d0a6b6a..e00cc48 100644
--- a/Prelude/List/filter
+++ b/Prelude/List/filter
@@ -17,14 +17,14 @@ let filter
       → λ(f : a → Bool)
       → λ(xs : List a)
       → List/build
-        a
-        (   λ(list : Type)
-          → λ(cons : a → list → list)
-          → List/fold
-            a
-            xs
-            list
-            (λ(x : a) → λ(xs : list) → if f x then cons x xs else xs)
-        )
+          a
+          (   λ(list : Type)
+            → λ(cons : a → list → list)
+            → List/fold
+                a
+                xs
+                list
+                (λ(x : a) → λ(xs : list) → if f x then cons x xs else xs)
+          )
 
 in  filter
diff --git a/Prelude/List/generate b/Prelude/List/generate
index cabe814..019b983 100644
--- a/Prelude/List/generate
+++ b/Prelude/List/generate
@@ -16,23 +16,23 @@ let generate
       → λ(a : Type)
       → λ(f : Natural → a)
       → List/build
-        a
-        (   λ(list : Type)
-          → λ(cons : a → list → list)
-          → List/fold
-            { index : Natural, value : {} }
-            ( List/indexed
-              {}
-              ( List/build
-                {}
-                (   λ(list : Type)
-                  → λ(cons : {} → list → list)
-                  → Natural/fold n list (cons {=})
+          a
+          (   λ(list : Type)
+            → λ(cons : a → list → list)
+            → List/fold
+                { index : Natural, value : {} }
+                ( List/indexed
+                    {}
+                    ( List/build
+                        {}
+                        (   λ(list : Type)
+                          → λ(cons : {} → list → list)
+                          → Natural/fold n list (cons {=})
+                        )
+                    )
                 )
-              )
-            )
-            list
-            (λ(x : { index : Natural, value : {} }) → cons (f x.index))
-        )
+                list
+                (λ(x : { index : Natural, value : {} }) → cons (f x.index))
+          )
 
 in  generate
diff --git a/Prelude/List/iterate b/Prelude/List/iterate
index 4c38905..69cb1d6 100644
--- a/Prelude/List/iterate
+++ b/Prelude/List/iterate
@@ -19,25 +19,25 @@ let iterate
       → λ(f : a → a)
       → λ(x : a)
       → List/build
-        a
-        (   λ(list : Type)
-          → λ(cons : a → list → list)
-          → List/fold
-            { index : Natural, value : {} }
-            ( List/indexed
-              {}
-              ( List/build
-                {}
-                (   λ(list : Type)
-                  → λ(cons : {} → list → list)
-                  → Natural/fold n list (cons {=})
+          a
+          (   λ(list : Type)
+            → λ(cons : a → list → list)
+            → List/fold
+                { index : Natural, value : {} }
+                ( List/indexed
+                    {}
+                    ( List/build
+                        {}
+                        (   λ(list : Type)
+                          → λ(cons : {} → list → list)
+                          → Natural/fold n list (cons {=})
+                        )
+                    )
                 )
-              )
-            )
-            list
-            (   λ(y : { index : Natural, value : {} })
-              → cons (Natural/fold y.index a f x)
-            )
-        )
+                list
+                (   λ(y : { index : Natural, value : {} })
+                  → cons (Natural/fold y.index a f x)
+                )
+          )
 
 in  iterate
diff --git a/Prelude/List/map b/Prelude/List/map
index 04196db..8e087b6 100644
--- a/Prelude/List/map
+++ b/Prelude/List/map
@@ -18,10 +18,10 @@ let map
       → λ(f : a → b)
       → λ(xs : List a)
       → List/build
-        b
-        (   λ(list : Type)
-          → λ(cons : b → list → list)
-          → List/fold a xs list (λ(x : a) → cons (f x))
-        )
+          b
+          (   λ(list : Type)
+            → λ(cons : b → list → list)
+            → List/fold a xs list (λ(x : a) → cons (f x))
+          )
 
 in  map
diff --git a/Prelude/List/replicate b/Prelude/List/replicate
index 42c8b0f..6360864 100644
--- a/Prelude/List/replicate
+++ b/Prelude/List/replicate
@@ -15,10 +15,10 @@ let replicate
       → λ(a : Type)
       → λ(x : a)
       → List/build
-        a
-        (   λ(list : Type)
-          → λ(cons : a → list → list)
-          → Natural/fold n list (cons x)
-        )
+          a
+          (   λ(list : Type)
+            → λ(cons : a → list → list)
+            → Natural/fold n list (cons x)
+          )
 
 in  replicate
diff --git a/Prelude/List/shifted b/Prelude/List/shifted
index 3884e80..e0fab90 100644
--- a/Prelude/List/shifted
+++ b/Prelude/List/shifted
@@ -42,45 +42,47 @@ let shifted
     =   λ(a : Type)
       → λ(kvss : List (List { index : Natural, value : a }))
       → List/build
-        { index : Natural, value : a }
-        (   λ(list : Type)
-          → λ(cons : { index : Natural, value : a } → list → list)
-          → λ(nil : list)
-          → let result =
-                  List/fold
-                  (List { index : Natural, value : a })
-                  kvss
-                  { count : Natural, diff : Natural → list }
-                  (   λ(kvs : List { index : Natural, value : a })
-                    → λ(y : { count : Natural, diff : Natural → list })
-                    → let length =
-                            List/length { index : Natural, value : a } kvs
-                      
-                      in  { count =
-                              y.count + length
-                          , diff =
-                                λ(n : Natural)
-                              → List/fold
-                                { index : Natural, value : a }
-                                kvs
-                                list
-                                (   λ(kvOld : { index : Natural, value : a })
-                                  → λ(z : list)
-                                  → let kvNew =
-                                          { index =
-                                              kvOld.index + n
-                                          , value =
-                                              kvOld.value
-                                          }
-                                    
-                                    in  cons kvNew z
-                                )
-                                (y.diff (n + length))
-                          }
-                  )
-                  { count = 0, diff = λ(_ : Natural) → nil }
-            
-            in  result.diff 0
-        )
+          { index : Natural, value : a }
+          (   λ(list : Type)
+            → λ(cons : { index : Natural, value : a } → list → list)
+            → λ(nil : list)
+            → let result =
+                    List/fold
+                      (List { index : Natural, value : a })
+                      kvss
+                      { count : Natural, diff : Natural → list }
+                      (   λ(kvs : List { index : Natural, value : a })
+                        → λ(y : { count : Natural, diff : Natural → list })
+                        → let length =
+                                List/length { index : Natural, value : a } kvs
+                          
+                          in  { count =
+                                  y.count + length
+                              , diff =
+                                    λ(n : Natural)
+                                  → List/fold
+                                      { index : Natural, value : a }
+                                      kvs
+                                      list
+                                      (   λ ( kvOld
+                                            : { index : Natural, value : a }
+                                            )
+                                        → λ(z : list)
+                                        → let kvNew =
+                                                { index =
+                                                    kvOld.index + n
+                                                , value =
+                                                    kvOld.value
+                                                }
+                                          
+                                          in  cons kvNew z
+                                      )
+                                      (y.diff (n + length))
+                              }
+                      )
+                      { count = 0, diff = λ(_ : Natural) → nil }
+              
+              in  result.diff 0
+          )
 
 in  shifted
diff --git a/Prelude/List/unzip b/Prelude/List/unzip
index 7ea74aa..a32dd7d 100644
--- a/Prelude/List/unzip
+++ b/Prelude/List/unzip
@@ -30,26 +30,26 @@ let unzip
       → λ(xs : List { _1 : a, _2 : b })
       → { _1 =
             List/build
-            a
-            (   λ(list : Type)
-              → λ(cons : a → list → list)
-              → List/fold
-                { _1 : a, _2 : b }
-                xs
-                list
-                (λ(x : { _1 : a, _2 : b }) → cons x._1)
-            )
+              a
+              (   λ(list : Type)
+                → λ(cons : a → list → list)
+                → List/fold
+                    { _1 : a, _2 : b }
+                    xs
+                    list
+                    (λ(x : { _1 : a, _2 : b }) → cons x._1)
+              )
         , _2 =
             List/build
-            b
-            (   λ(list : Type)
-              → λ(cons : b → list → list)
-              → List/fold
-                { _1 : a, _2 : b }
-                xs
-                list
-                (λ(x : { _1 : a, _2 : b }) → cons x._2)
-            )
+              b
+              (   λ(list : Type)
+                → λ(cons : b → list → list)
+                → List/fold
+                    { _1 : a, _2 : b }
+                    xs
+                    list
+                    (λ(x : { _1 : a, _2 : b }) → cons x._2)
+              )
         }
 
 in  unzip
diff --git a/Prelude/Map/map b/Prelude/Map/map
index b7a455c..2ae39ee 100644
--- a/Prelude/Map/map
+++ b/Prelude/Map/map
@@ -40,11 +40,11 @@ let map
       → λ(f : a → b)
       → λ(m : Map k a)
       → List/map
-        (Entry k a)
-        (Entry k b)
-        (   λ(before : Entry k a)
-          → { mapKey = before.mapKey, mapValue = f before.mapValue }
-        )
-        m
+          (Entry k a)
+          (Entry k b)
+          (   λ(before : Entry k a)
+            → { mapKey = before.mapKey, mapValue = f before.mapValue }
+          )
+          m
 
 in  map
diff --git a/Prelude/Natural/enumerate b/Prelude/Natural/enumerate
index 1de7af4..4481f9d 100644
--- a/Prelude/Natural/enumerate
+++ b/Prelude/Natural/enumerate
@@ -14,23 +14,23 @@ let enumerate
     : Natural → List Natural
     =   λ(n : Natural)
       → List/build
-        Natural
-        (   λ(list : Type)
-          → λ(cons : Natural → list → list)
-          → List/fold
-            { index : Natural, value : {} }
-            ( List/indexed
-              {}
-              ( List/build
-                {}
-                (   λ(list : Type)
-                  → λ(cons : {} → list → list)
-                  → Natural/fold n list (cons {=})
+          Natural
+          (   λ(list : Type)
+            → λ(cons : Natural → list → list)
+            → List/fold
+                { index : Natural, value : {} }
+                ( List/indexed
+                    {}
+                    ( List/build
+                        {}
+                        (   λ(list : Type)
+                          → λ(cons : {} → list → list)
+                          → Natural/fold n list (cons {=})
+                        )
+                    )
                 )
-              )
-            )
-            list
-            (λ(x : { index : Natural, value : {} }) → cons x.index)
-        )
+                list
+                (λ(x : { index : Natural, value : {} }) → cons x.index)
+          )
 
 in  enumerate
diff --git a/Prelude/Optional/concat b/Prelude/Optional/concat
index 652d178..87f4909 100644
--- a/Prelude/Optional/concat
+++ b/Prelude/Optional/concat
@@ -19,10 +19,10 @@ let concat
     =   λ(a : Type)
       → λ(x : Optional (Optional a))
       → Optional/fold
-        (Optional a)
-        x
-        (Optional a)
-        (λ(y : Optional a) → y)
-        (None a)
+          (Optional a)
+          x
+          (Optional a)
+          (λ(y : Optional a) → y)
+          (None a)
 
 in  concat
diff --git a/Prelude/Optional/filter b/Prelude/Optional/filter
index 85ff364..3fe743b 100644
--- a/Prelude/Optional/filter
+++ b/Prelude/Optional/filter
@@ -17,16 +17,16 @@ let filter
       → λ(f : a → Bool)
       → λ(xs : Optional a)
       → Optional/build
-        a
-        (   λ(optional : Type)
-          → λ(some : a → optional)
-          → λ(none : optional)
-          → Optional/fold
-            a
-            xs
-            optional
-            (λ(x : a) → if f x then some x else none)
-            none
-        )
+          a
+          (   λ(optional : Type)
+            → λ(some : a → optional)
+            → λ(none : optional)
+            → Optional/fold
+                a
+                xs
+                optional
+                (λ(x : a) → if f x then some x else none)
+                none
+          )
 
 in  filter
diff --git a/Prelude/Optional/head b/Prelude/Optional/head
index 67ff510..56d64de 100644
--- a/Prelude/Optional/head
+++ b/Prelude/Optional/head
@@ -16,13 +16,13 @@ let head
     =   λ(a : Type)
       → λ(xs : List (Optional a))
       → List/fold
-        (Optional a)
-        xs
-        (Optional a)
-        (   λ(l : Optional a)
-          → λ(r : Optional a)
-          → Optional/fold a l (Optional a) (λ(x : a) → Some x) r
-        )
-        (None a)
+          (Optional a)
+          xs
+          (Optional a)
+          (   λ(l : Optional a)
+            → λ(r : Optional a)
+            → Optional/fold a l (Optional a) (λ(x : a) → Some x) r
+          )
+          (None a)
 
 in  head
diff --git a/Prelude/Optional/last b/Prelude/Optional/last
index 2d1431a..b8d555d 100644
--- a/Prelude/Optional/last
+++ b/Prelude/Optional/last
@@ -16,13 +16,13 @@ let last
     =   λ(a : Type)
       → λ(xs : List (Optional a))
       → List/fold
-        (Optional a)
-        xs
-        (Optional a)
-        (   λ(l : Optional a)
-          → λ(r : Optional a)
-          → Optional/fold a r (Optional a) (λ(x : a) → Some x) l
-        )
-        (None a)
+          (Optional a)
+          xs
+          (Optional a)
+          (   λ(l : Optional a)
+            → λ(r : Optional a)
+            → Optional/fold a r (Optional a) (λ(x : a) → Some x) l
+          )
+          (None a)
 
 in  last
diff --git a/Prelude/Optional/unzip b/Prelude/Optional/unzip
index 8629960..a1e6807 100644
--- a/Prelude/Optional/unzip
+++ b/Prelude/Optional/unzip
@@ -21,18 +21,18 @@ let unzip
       → λ(xs : Optional { _1 : a, _2 : b })
       → { _1 =
             Optional/fold
-            { _1 : a, _2 : b }
-            xs
-            (Optional a)
-            (λ(x : { _1 : a, _2 : b }) → Some x._1)
-            (None a)
+              { _1 : a, _2 : b }
+              xs
+              (Optional a)
+              (λ(x : { _1 : a, _2 : b }) → Some x._1)
+              (None a)
         , _2 =
             Optional/fold
-            { _1 : a, _2 : b }
-            xs
-            (Optional b)
-            (λ(x : { _1 : a, _2 : b }) → Some x._2)
-            (None b)
+              { _1 : a, _2 : b }
+              xs
+              (Optional b)
+              (λ(x : { _1 : a, _2 : b }) → Some x._2)
+              (None b)
         }
 
 in  unzip
diff --git a/Prelude/Text/concatMapSep b/Prelude/Text/concatMapSep
index f2512a8..77e2298 100644
--- a/Prelude/Text/concatMapSep
+++ b/Prelude/Text/concatMapSep
@@ -20,21 +20,21 @@ let concatMapSep
       → λ(elements : List a)
       → let status =
               List/fold
-              a
-              elements
-              Status
-              (   λ(x : a)
-                → λ(status : Status)
-                → merge
-                  { Empty =
-                      Status.NonEmpty (f x)
-                  , NonEmpty =
-                        λ(result : Text)
-                      → Status.NonEmpty (f x ++ separator ++ result)
-                  }
-                  status
-              )
-              Status.Empty
+                a
+                elements
+                Status
+                (   λ(x : a)
+                  → λ(status : Status)
+                  → merge
+                      { Empty =
+                          Status.NonEmpty (f x)
+                      , NonEmpty =
+                            λ(result : Text)
+                          → Status.NonEmpty (f x ++ separator ++ result)
+                      }
+                      status
+                )
+                Status.Empty
         
         in  merge { Empty = "", NonEmpty = λ(result : Text) → result } status
 
diff --git a/Prelude/Text/concatSep b/Prelude/Text/concatSep
index ff8edf1..a158ef4 100644
--- a/Prelude/Text/concatSep
+++ b/Prelude/Text/concatSep
@@ -17,21 +17,21 @@ let concatSep
       → λ(elements : List Text)
       → let status =
               List/fold
-              Text
-              elements
-              Status
-              (   λ(element : Text)
-                → λ(status : Status)
-                → merge
-                  { Empty =
-                      Status.NonEmpty element
-                  , NonEmpty =
-                        λ(result : Text)
-                      → Status.NonEmpty (element ++ separator ++ result)
-                  }
-                  status
-              )
-              Status.Empty
+                Text
+                elements
+                Status
+                (   λ(element : Text)
+                  → λ(status : Status)
+                  → merge
+                      { Empty =
+                          Status.NonEmpty element
+                      , NonEmpty =
+                            λ(result : Text)
+                          → Status.NonEmpty (element ++ separator ++ result)
+                      }
+                      status
+                )
+                Status.Empty
         
         in  merge { Empty = "", NonEmpty = λ(result : Text) → result } status
 
diff --git a/Prelude/XML/element b/Prelude/XML/element
index c48508f..57b12e5 100644
--- a/Prelude/XML/element
+++ b/Prelude/XML/element
@@ -56,12 +56,12 @@ let element
             }
           )
       → xml.element
-        { attributes =
-            elem.attributes
-        , name =
-            elem.name
-        , content =
-            List/map XML@1 XML (λ(x : XML@1) → x XML xml) elem.content
-        }
+          { attributes =
+              elem.attributes
+          , name =
+              elem.name
+          , content =
+              List/map XML@1 XML (λ(x : XML@1) → x XML xml) elem.content
+          }
 
 in  element
diff --git a/Prelude/XML/render b/Prelude/XML/render
index 359015d..43692fb 100644
--- a/Prelude/XML/render
+++ b/Prelude/XML/render
@@ -42,28 +42,29 @@ let render
     : XML → Text
     =   λ(x : XML)
       → x
-        Text
-        { text =
-            λ(d : Text) → d
-        , element =
-              λ ( elem
-                : { attributes :
-                      List { mapKey : Text, mapValue : Text }
-                  , content :
-                      List Text
-                  , name :
-                      Text
-                  }
-                )
-            → let attribs = Text/concatMap Attr renderAttr elem.attributes
-              
-              in      "<${elem.name}${attribs}"
-                  ++  (       if Natural/isZero (List/length Text elem.content)
-                        
-                        then  "/>"
-                        
-                        else  ">${Text/concat elem.content}</${elem.name}>"
-                      )
-        }
+          Text
+          { text =
+              λ(d : Text) → d
+          , element =
+                λ ( elem
+                  : { attributes :
+                        List { mapKey : Text, mapValue : Text }
+                    , content :
+                        List Text
+                    , name :
+                        Text
+                    }
+                  )
+              → let attribs = Text/concatMap Attr renderAttr elem.attributes
+                
+                in      "<${elem.name}${attribs}"
+                    ++  (       if Natural/isZero
+                                     (List/length Text elem.content)
+                          
+                          then  "/>"
+                          
+                          else  ">${Text/concat elem.content}</${elem.name}>"
+                        )
+          }
 
 in  render

@Gabriella439 Gabriella439 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! 🙂

@mergify
mergify Bot merged commit 22d4610 into dhall-lang:master Jul 29, 2019
ocharles added a commit to dhall-lang/dhall-lang that referenced this pull request Aug 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Could we format multi-line function calls with arguments intended?

2 participants