Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Difference between classic style and ormolu style diffs #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions haskell/ormolu-trailing-comma/classic.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ lists =
[ "It is often lists do not fit into a single line."
, "We need to format them in a readable fashion"
, "without compromising functionality."
, "Placement of commas at the end increases git diffs!"
]

data Record =
Record
{ records :: String
, are :: Bool
, no :: Bool
, exception :: SomeException
}

myRecord :: Record
Expand All @@ -23,6 +25,7 @@ myRecord =
{ records = "Records are also suscpetible to trailing comma problem"
, are = True
, no = False
, exception = toException StackOverflow
}


Expand All @@ -32,9 +35,11 @@ tuples ::
( String
, String
, VeryLongTypeNameThatCausesForTupleiInTheTypeSignatureToWrapAroundTooAmIRight
, Bool
)
tuples =
( "It is less common for tuples to not fit into a single line."
, "However it does still happen"
, AmIRight
, True
)
46 changes: 41 additions & 5 deletions haskell/ormolu-trailing-comma/ormolu.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,68 @@ lists :: [String]
lists =
[ "It is often that lists do not fit into a single line.",
"We need to format them in a readable fashion",
"without compromising functionality."
"without compromising functionality.",
"Placement of commas at the end increases git diffs!"
]

data Record = Record
{ records :: String,
are :: Bool,
no :: Bool
no :: Bool,
exception :: SomeException
}

myRecord :: Record
myRecord =
Record
{ records = "Records are aslo suscpetible to trailing comma problem",
are = True,
no = False
no = False,
exception = toException StackOverflow
}

data VeryLongTypeNameThatCausesForTupleiInTheTypeSignatureToWrapAroundTooAmIRight = AmIRight

tuples ::
( String,
String,
VeryLongTypeNameThatCausesForTupleiInTheTypeSignatureToWrapAroundTooAmIRight
VeryLongTypeNameThatCausesForTupleiInTheTypeSignatureToWrapAroundTooAmIRight,
Bool
)
tuples =
( "It is less common for tuples to not fit into a single line.",
"However it does still happen",
AmIRight
AmIRight,
True
)


foo :: Num a => (a, a, a) -> a
foo ( x
, y
, z
) = x + y + z


bar :: Num a => [a] -> a
bar [ x
, y
, z
] = x + y + z


baz :: Num a => [a] -> a
baz xs =
case xs of
Foo [ x
, y
, z
] -> x + y + z
_ -> 0

bar :: Num a => [a] -> a
bar [ x
, y
, z
] = x + y + z
bar _ = 0
2 changes: 1 addition & 1 deletion haskell/vector/slice.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
module Main where

import Control.Exception
import Control.Monad as M
import Data.List as List
import qualified Data.Vector as V
import qualified Data.Vector.Generic as VG
Expand Down Expand Up @@ -33,6 +32,7 @@ printSlices name sliceWith xs = do
tryErrorPrint " too large size: " (sliceWith 2 6 xs)
tryErrorPrint " too large ix size: " (sliceWith 6 6 xs)

main :: IO ()
main = do
let xs = [1, 2, 3, 4, 5] :: [Int]
printSlices "List" sliceList xs
Expand Down
Binary file modified haskell/vector/take-drop
Binary file not shown.