Skip to content

Parenthesized function type gets an extra indent level where no outer function type needs it #3554

Closed

Description

@nojaf

Issue created from fantomas-online

Code

type T = (LongTypeNameNumberOne -> LongTypeNameNumberTwo -> LongTypeNameNumberThree -> LongTypeNameNumberFour -> LongTypeNameNumberFive) list

Result

type T =
    (LongTypeNameNumberOne
            -> LongTypeNameNumberTwo
            -> LongTypeNameNumberThree
            -> LongTypeNameNumberFour
            -> LongTypeNameNumberFive) list

Problem description

Since 8.0.0-alpha-003 (#3225, the fix for #3043), every multiline parenthesized function type indents its -> lines one extra level. 7.0.6 and 8.0.0-alpha-002 put them one level past (. 8.0.0-alpha-003, 8.0.10 and main put them two levels past it.

The extra level is only needed when the parenthesized type is part of an outer function type, as in #3043: there the old layout gives FS0010: Incomplete structured construct. I compiled the 7.0.6 layout in each context:

  • let f : string -> (a -> b -> c) -> unit (Invalid multiline function type #3043): fails
  • type T = string -> (a -> b -> c) -> unit: fails
  • type T = (a -> b -> c) list (this sample): compiles
  • type application f<(a -> b -> c) list>: compiles
  • union case | Case of (a -> b -> c): compiles
  • record field F : (a -> b -> c): compiles

Expected: the extra level only inside an outer function type, and the 7.0.6 layout otherwise.

Extra information

  • The formatted result breaks my code.
  • The formatted result gives compiler warnings.
  • I or my company would be willing to help fix this.
  • I would like a release if this problem is solved.

Options

Fantomas main branch at 2026-10-17T10:43:43Z - f734124

Default Fantomas configuration

Did you know that you can ignore files when formatting by using a .fantomasignore file?
PS: It's unlikely that someone else will solve your specific issue, as it's something that you have a personal stake in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions