Module design: When to use a pipeline and when to fold a list?

This is a very good example as it illustrates the conflict very well.

I have a slight preference for the pipeline version in this case because the “things” are heterogeneous but this is only a slight preference as my mind cannot ignore the fact that Something is a record and that I would always write that using Elm syntax.

test : Something
test =
    { default
        | field1 = "foo"
        , field2 = 5
        , field3 = 0.5
    }

Later edit, if you want to mimic the elm/html API, you could go for the list version.


type alias Options = 
    { foo : String 
    , bar : Int 
    }

type alias Attr = Options -> Options 

foo : String -> Attr 
foo theFoo options = 
     { options | foo = theFoo } 


apiEndpoint : List (Attr) -> SomeResult 
apiEndpoint attrs = 
    let 
        options = List.fold identity defaultOptions attrs 
    in 
    ...