the-sett / elm-syntax-dsl

A DSL for creating Elm syntax trees and pretty printing Elm source code.
BSD 3-Clause "New" or "Revised" License
20 stars 4 forks source link

Vertical type aliases for records. #12

Open rupertlssmith opened 5 years ago

rupertlssmith commented 5 years ago

The pretty printer can fit records onto single lines:

type alias AccessKeyMetadata =
    { userName : UserNameType, status : StatusType, createDate : DateType, accessKeyId : AccessKeyIdType }

but this is definitely better broken:

type alias AccessKeyMetadata =
    { userName : UserNameType
    , status : StatusType
    , createDate : DateType
    , accessKeyId : AccessKeyIdType
    }

A better rule is break if >1 field.

Only want to force break in the alias definition, not in pattern matches like { userName, status, createDate, accessKeyId } or in expressions that build records, or in type annotations.

{-| Calc distance between two things that can be 2d points. -}
distance : { a | x : Int, y : Int } -> { b | x : Int, y : Int } ->  Int