purescript-prelude icon indicating copy to clipboard operation
purescript-prelude copied to clipboard

add liftCompare & friends

Open flip111 opened this issue 2 years ago • 5 comments

Could a function like this be added? https://hackage.haskell.org/package/base-4.19.0.0/docs/Data-Functor-Classes.html#v:liftCompare

In which module should such function go?

flip111 avatar Jan 24 '24 18:01 flip111

What is f in the above context? Due to liftCompare lacking any type class constraints, how would you get the a or b out of f?

JordanMartinez avatar Jan 25 '24 15:01 JordanMartinez

Does the class definition give sufficient information?

class (Eq1 f, forall a. Ord a => Ord (f a)) => Ord1 (f :: Type -> Type) where

Related https://pursuit.purescript.org/packages/purescript-prelude/6.0.1/docs/Data.Ord#t:Ord1 https://pursuit.purescript.org/packages/purescript-prelude/6.0.1/docs/Data.Eq#t:Eq1

flip111 avatar Jan 26 '24 01:01 flip111

We don't yet support this syntax on the left side of the =>:

forall a. Ord a => Ord (f a)

How would we implement this?

JordanMartinez avatar Jan 26 '24 11:01 JordanMartinez

How would we implement this?

Part of the purpose of Ord1 is to avoid that constraint, there's an Ord a constraint on compare1 instead.

garyb avatar Jan 26 '24 14:01 garyb

Ok, I misread the Haskell docs. I thought liftCompare was a function, not a type class member... That explains a lot.

JordanMartinez avatar Jan 26 '24 20:01 JordanMartinez