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

Suggestion for {-# MINIMAL #-} pragma placement #15

Open
hvr opened this issue Sep 23, 2014 · 0 comments
Open

Suggestion for {-# MINIMAL #-} pragma placement #15

hvr opened this issue Sep 23, 2014 · 0 comments

Comments

@hvr
Copy link

hvr commented Sep 23, 2014

The general recommendation seems to be to place pragmas after the entity they apply to. But in case of the {-# MINIMAL #-} pragma, I think the following works best in terms of readability:

class Foldable t where
    {-# MINIMAL foldMap | foldr #-}

    -- | Combine the elements of a structure using a monoid.
    fold :: Monoid m => t m -> m
    fold = foldMap id

   {- long list of other methods -}

    -- | List of elements of a structure.
    toList :: Foldable t => t a -> [a]
    toList t = build (\ c n -> foldr c n t)
    {-# INLINE toList #-}

as opposed to place the {-# MINIMAL #-}-line after the {-# INLINE toList #-}-line.

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

No branches or pull requests

1 participant