Skip to content

re-add Alternate newtype#50

Merged
garyb merged 1 commit intopurescript:masterfrom
Thimoteus:alternate-newtype
Jul 17, 2018
Merged

re-add Alternate newtype#50
garyb merged 1 commit intopurescript:masterfrom
Thimoteus:alternate-newtype

Conversation

@Thimoteus
Copy link
Copy Markdown
Contributor

Since the merge of the deprecated monoid lib into Prelude, all the newtypes except this were kept. This can't fit in the prelude, because Alt exists here.

@Thimoteus
Copy link
Copy Markdown
Contributor Author

Thimoteus commented Jul 16, 2018

Hmm, I just realized that since control doesn't depend on newtype it's not possible to do ala Alternate foldMap. In fact, it's not possible to do that with any of the newtypes from the old monoid library (though this is a seperate issue).

append (Alternate a) (Alternate b) = Alternate (a <|> b)

instance monoidAlternate :: Plus f => Monoid (Alternate f a) where
mempty = Alternate empty No newline at end of file
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry to be super nitpicky, but can you put an empty newline at the end of the file too please?


derive newtype instance eqAlternate :: Eq (f a) => Eq (Alternate f a)

derive newtype instance ordAlternate :: Ord (f a) => Ord (Alternate f a)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add Eq1 and Ord1 instances while we're here? You should be able to derive them I think, with Eq1 / Ord1 constraints on f.

@Thimoteus Thimoteus force-pushed the alternate-newtype branch from d7822b7 to a5c1b6e Compare July 17, 2018 01:34
@Thimoteus
Copy link
Copy Markdown
Contributor Author

Updated

@garyb
Copy link
Copy Markdown
Member

garyb commented Jul 17, 2018

Thanks!

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

Successfully merging this pull request may close these issues.

2 participants