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

Formatting higher order functions and forall's #46

Open
merc1031 opened this issue Jun 17, 2020 · 1 comment
Open

Formatting higher order functions and forall's #46

merc1031 opened this issue Jun 17, 2020 · 1 comment

Comments

@merc1031
Copy link

What I am aiming for

{-# LANGUAGE ExplicitForAll #-}

module Main where

fn
  :: forall m s
   . ( Constraint m
     , Constraint s
     )
  => (Type -> s)
  -> (forall a.  m a -> s -> IO a)
  -> Type
  -> (forall a.  m a -> IO a)
fn mkState runner kc
  = go
  where
    go
      :: m a
      -> IO a
    go act
      = runner act
      $ mkState kc

What I am getting from floskell (it could just be a config issue but im having a lot of trouble tweaking it to disambiguate the inner -> and .

{-# LANGUAGE ExplicitForAll #-}

module Main where

fn
  :: forall m s
  .  (Constraint m, Constraint s)
  => (Type
      -> s)
  -> (forall a
      .  m a
      -> s
      -> IO a)
  -> Type
  -> (forall a
      .  m a
      -> IO a)
fn mkState runner kc
  = go
  where
    go
      :: m a
      -> IO a
    go act
      = runner act
      $ mkState kc

In particular I cant seem to get the spacing around the outer . correct, or the disambiguation between inner and outer . and ->, and the vertical alignment of the constraints.

Here is a link to the config I have messed around with (https://gist.github.com/merc1031/25006873e4204efcc9f081b335e29a29)

Thanks

@ennocramer
Copy link
Owner

The alignment and padding of operators in vertical layouting is very ad-hoc and hard-coded at the moment. You will not be able to right-align . with => and -> at the moment.

There is also no way to distinguish operators based on some nesting level. The best choice you have at the moment is type: try-oneline with optional newlines before the operator. That will get you the linebreaks on the outermost arrows while keeping the inner arrows on one line, but only if the outer type expression is long enough to require multiple lines.

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

No branches or pull requests

2 participants