Add instance Eq1 Complex, Show1 Complex, and Read1 Complex

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Add instance Eq1 Complex, Show1 Complex, and Read1 Complex

Dannyu NDos
instance Eq1 Complex where
liftEq f (x :+ y) (u :+ v) = f x u && f y v

instance Show1 Complex where
liftShowsPrec sp _ p (x :+ y) = showParen (p >= 6) (sp p x . showString " :+ " . sp p y)

instance Read1 Complex where
liftReadPrec rp _ = parens $ prec 6 $ do
x <- step rp
Symbol ":+" <- lexP
y <- step rp
return (x :+ y)
liftReadList = liftReadListDefault
liftReadListPrec = liftReadListPrecDefault

_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

Re: Add instance Eq1 Complex, Show1 Complex, and Read1 Complex

Edward Kmett-2
Makes sense to me. +1

On Fri, Aug 9, 2019 at 6:15 PM Dannyu NDos <[hidden email]> wrote:
instance Eq1 Complex where
liftEq f (x :+ y) (u :+ v) = f x u && f y v

instance Show1 Complex where
liftShowsPrec sp _ p (x :+ y) = showParen (p >= 6) (sp p x . showString " :+ " . sp p y)

instance Read1 Complex where
liftReadPrec rp _ = parens $ prec 6 $ do
x <- step rp
Symbol ":+" <- lexP
y <- step rp
return (x :+ y)
liftReadList = liftReadListDefault
liftReadListPrec = liftReadListPrecDefault
_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

Re: Add instance Eq1 Complex, Show1 Complex, and Read1 Complex

chessai .
+1

On Fri, Aug 9, 2019, 10:26 PM Edward Kmett <[hidden email]> wrote:
Makes sense to me. +1

On Fri, Aug 9, 2019 at 6:15 PM Dannyu NDos <[hidden email]> wrote:
instance Eq1 Complex where
liftEq f (x :+ y) (u :+ v) = f x u && f y v

instance Show1 Complex where
liftShowsPrec sp _ p (x :+ y) = showParen (p >= 6) (sp p x . showString " :+ " . sp p y)

instance Read1 Complex where
liftReadPrec rp _ = parens $ prec 6 $ do
x <- step rp
Symbol ":+" <- lexP
y <- step rp
return (x :+ y)
liftReadList = liftReadListDefault
liftReadListPrec = liftReadListPrecDefault
_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

Re: Add instance Eq1 Complex, Show1 Complex, and Read1 Complex

George Wilson
+1

On Sat, 10 Aug 2019 at 12:51, chessai . <[hidden email]> wrote:

>
> +1
>
> On Fri, Aug 9, 2019, 10:26 PM Edward Kmett <[hidden email]> wrote:
>>
>> Makes sense to me. +1
>>
>> On Fri, Aug 9, 2019 at 6:15 PM Dannyu NDos <[hidden email]> wrote:
>>>
>>> instance Eq1 Complex where
>>> liftEq f (x :+ y) (u :+ v) = f x u && f y v
>>>
>>> instance Show1 Complex where
>>> liftShowsPrec sp _ p (x :+ y) = showParen (p >= 6) (sp p x . showString " :+ " . sp p y)
>>>
>>> instance Read1 Complex where
>>> liftReadPrec rp _ = parens $ prec 6 $ do
>>> x <- step rp
>>> Symbol ":+" <- lexP
>>> y <- step rp
>>> return (x :+ y)
>>> liftReadList = liftReadListDefault
>>> liftReadListPrec = liftReadListPrecDefault
>>> _______________________________________________
>>> Libraries mailing list
>>> [hidden email]
>>> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>>
>> _______________________________________________
>> Libraries mailing list
>> [hidden email]
>> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>
> _______________________________________________
> Libraries mailing list
> [hidden email]
> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries