-
-
Notifications
You must be signed in to change notification settings - Fork 24
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
instances Display List, Tuples ... #29
Comments
Yes please, although that would require figuring out how to deal with compositionality. |
On Mon, 18 Mar 2019, Heinrich Apfelmus wrote:
Yes please, although that would require figuring out how to deal with compositionality.
In the current Text-based design we could combine the objects with '<br>'.
However, Xhtml would require '<br/>'.
But hm, for lists of numbers you currently use showList, what makes sense, too.
I guess, there should be a DisplayList class
such that for every element type there can be a custom list instance.
|
A |
On Tue, 19 Mar 2019, Heinrich Apfelmus wrote:
A DisplayList class? I would like to stick to the trick that the Haskell
Prelude uses, namely that for every type, we also implements a showList
function that is responsible for showing a list of these things.
I think the 'showList' design was the answer to the problem, that the
Haskell creators wanted the single [Char] instance to behave differently
from all other list instances.
Is this the case here, too?
My DisplayList approach would be this one:
class DisplayList a where
displayList :: [a] -> Graphic
instance (DisplayList a) => Display [a] where
display = displayList
This would also avoid FlexibleInstances.
Maybe with a default implementation:
class (Display a) => DisplayList a where
displayList :: [a] -> Graphic
displayList = Text.intersperse (Text.pack "<br>") . map display
For graphical objects we might use the stacking with <br> and for numbers
we would use the list notation, i.e. [1,2,3].
|
I think we have the same problem: Some lists should be displayed differently from the default display, just like We do not have to introduce a
|
How about
Display
instances for lists and tuples? This would simplify displaying the results of functions that return multiple results. E.g. the tuple members could be displayed in tiers.The text was updated successfully, but these errors were encountered: