• gerryflap@feddit.nl
    link
    fedilink
    arrow-up
    10
    ·
    10 months ago

    I’ve written Haskell quite a bit, and I don’t fully understand why this is called Haskell style. Haskell code looks nothing like this, the syntax is completely different. For Haskell’s syntax I think it works fine, because I never noticed something weird. But this code in “Haskell style” looks absolutely insane

    • t_veor@sopuli.xyz
      link
      fedilink
      arrow-up
      11
      ·
      10 months ago

      It’s sometimes called comma-leading style where you move all the special characters to the front of the line and it is exceedingly common in Haskell, possibly due to how Haskell treats significant whitespace. You’ve surely seen list definitions that look like this:

      someList =
        [ 1
        , 2
        , 3
        ] 
      

      or a data definition like this:

      data Color
        = Red
        | Green
        | Blue
        | RGB Int Int Int
        deriving (Show, Eq)
      

      or a list of module exports like this:

      module Foo
        { bar
        , baz
        , quux
        } 
      

      Or in a long function type declaration where the arrows are moved to the start of the line, or a record definition, etc. etc.