Skip to content

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
    • Help
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
P
purty
  • Project
    • Project
    • Details
    • Activity
    • Releases
    • Cycle Analytics
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Charts
    • Locked Files
  • Issues 23
    • Issues 23
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge Requests 2
    • Merge Requests 2
  • CI / CD
    • CI / CD
    • Pipelines
    • Schedules
  • Registry
    • Registry
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Charts
  • Create a new issue
  • Commits
  • Issue Boards
  • Hardy Jones
  • purty
  • Issues
  • #10

Closed
Open
Opened Apr 07, 2018 by Hardy Jones@joneshf
  • Report abuse
  • New issue
Report abuse New issue

Support dynamic and static printing

it's pretty clear that the way we print currently isn't all that pretty.

While it makes sense to break on long lines, it's also not the only way to pretty print. We can also layout everything statically (with the same rules at all times). Static layout rules mean that printing becomes more consistent and predictable. Static layout rules also mean that even stuff that could fit on one line might be broken up into multiple lines. Depends on the layout rules.

Copying text of issues for posterity

From

  • https://github.com/joneshf/purty/issues/3

    class 
      ( Patch ad
      ) <=
      Diff a d | a -> d where
        diff ::
          a ->
          a ->
          d
  • https://github.com/joneshf/purty/issues/4

    map ::
      forall a b da db.
      Patch ada =>
      Patch bdb =>
      (Jet a -> Jet b) ->
      Jet (IArray a) ->
      Jet (IArray b)
    map f { position: IArray xs, velocity: dxs } = let go (InsertAt i a) = Just (InsertAt i (f (constant a))."position")
                                                      go (DeleteAt i) = Just (DeleteAt i)
                                                      go (ModifyAt i da) = (xs !! i) <#> \a ->
                                                          let j = f { "position": a
                                                                    , "velocity": toChange da
                                                                    }
    
                                                          in ModifyAt i (fromChange j."velocity")
    
                                                  in { "position": IArray (Prelude.map (_."position" <<< f <<< constant) xs)
                                                      , "velocity": toChange (mapMaybe go (fromChange dxs))
                                                      }
  • https://github.com/joneshf/purty/issues/6

    From

    module Main where
    
    import Prelude
    import Control.Monad.Eff.Console
    
    type T = { foo :: Int, bar :: { baz :: Int, qux :: { lhs :: Int, rhs :: Int } } }
    
    init :: T
    init = { foo: 1, bar: { baz: 2, qux: { lhs: 3, rhs: 4 } } }
    
    updated :: T
    updated = init { foo = 10, bar { baz = 20, qux { lhs = 30, rhs = 40 } } }
    
    expected :: T
    expected = { foo: 10, bar: { baz: 20, qux: { lhs: 30, rhs: 40 } } }
    
    check l r =
      l.foo == r.foo &&
      l.bar.baz == r.bar.baz &&
      l.bar.qux.lhs == r.bar.qux.lhs &&
      l.bar.qux.rhs == r.bar.qux.rhs
    
    main = do
      when (check updated expected) $ log "Done"

    to

    module Main where
    
    import Prelude 
    import Control.Monad.Eff.Console 
    
    type T
      = {"foo" :: Int, "bar" :: {"baz" :: Int, "qux" :: {"lhs" :: Int, "rhs" :: Int}}}
    init ::
      T
    init = { "foo": 1
          , "bar": { "baz": 2
                    , "qux": {"lhs": 3, "rhs": 4}
                    }
          }
    
    updated ::
      T
    updated = init { "foo" = 10
                  , "bar" { "baz" = 20
                          , "qux" {"lhs" = 30, "rhs" = 40}
                          }
                  }
    
    expected ::
      T
    expected = { "foo": 10
              , "bar": { "baz": 20
                        , "qux": {"lhs": 30, "rhs": 40}
                        }
              }
    
    check l r = l."foo" == r."foo" && l."bar"."baz" == r."bar"."baz" && l."bar"."qux"."lhs" == r."bar"."qux"."lhs" && l."bar"."qux"."rhs" == r."bar"."qux"."rhs"
    
    main = do
        when (check updated expected) $ log "Done"
Edited Apr 25, 2018 by Hardy Jones

Related issues

Assignee
Assign to
0.4.0
Milestone
0.4.0
Assign milestone
Time tracking
None
Due date
No due date
2
Labels
Done feature
Assign labels
  • View project labels
Reference: joneshf/purty#10