Commit 626d7b35 authored by Mart Lubbers's avatar Mart Lubbers Committed by Camil Staps

Add toString instances for tuples of 2 to 5 elements

parent 82abcd7a
Pipeline #31953 passed with stage
in 3 minutes and 7 seconds
......@@ -6,6 +6,7 @@ from Data.Monoid import class Semigroup, class Monoid
from Data.Foldable import class Foldable
from Data.Traversable import class Traversable
from Data.Bifunctor import class Bifunctor
from StdOverloaded import class toString
tuple :: .a .b -> .(.a,.b)
tuple3 :: .a .b .c -> .(.a,.b,.c)
......@@ -59,3 +60,8 @@ instance Bifunctor (,)
instance Bifunctor ((,,) x)
instance Bifunctor ((,,,) x y)
instance Bifunctor ((,,,,) x y z)
instance toString (a, b) | toString a & toString b
instance toString (a, b, c) | toString a & toString b & toString c
instance toString (a, b, c, d) | toString a & toString b & toString c & toString d
instance toString (a, b, c, d, e) | toString a & toString b & toString c & toString d & toString e
......@@ -9,6 +9,10 @@ import Data.Monoid
import Data.Foldable
import Data.Traversable
import Control.Applicative
import StdOverloaded
import StdString
from Text import class Text, instance Text String
import qualified Text
tuple :: .a .b -> .(.a,.b)
tuple a b = (a,b)
......@@ -132,3 +136,19 @@ where
instance Bifunctor ((,,,,) x y z)
where
bifmap f g t = let (x, y, z, a, b) = t in (x, y, z, f a, g b)
instance toString (a, b) | toString a & toString b
where
toString (a, b) = 'Text'.concat ["(", toString a, ", ", toString b, ")"]
instance toString (a, b, c) | toString a & toString b & toString c
where
toString (a, b, c) = 'Text'.concat ["(", toString a, ", ", toString b, ", ", toString c, ")"]
instance toString (a, b, c, d) | toString a & toString b & toString c & toString d
where
toString (a, b, c, d) = 'Text'.concat ["(", toString a, ", ", toString b, ", ", toString c, ", ", toString d, ")"]
instance toString (a, b, c, d, e) | toString a & toString b & toString c & toString d & toString e
where
toString (a, b, c, d, e) = 'Text'.concat ["(", toString a, ", ", toString b, ", ", toString c, ", ", toString d, ", ", toString e, ")"]
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment