Closed babhishek21 closed 8 years ago
I hope my use of the if-then-else construct was justified
Yep.
I don't fully understand why
oldValue == Text.empty
or(Text.null oldValue)
don't work
Text.null
doesn't work because of how Haskell import syntax works. In T.null
, T
is the module alias and null
is the name of the function. Now:
Data.Text
is imported like import qualified Data.Text as T
, it makes T
refer to Data.Text
.Data.Text
was imported like import Data.Text as T
, it'd make null
available both as null
and as T.null
. People don't usually import Data.Text
like that because lots of names there clash with ones in Prelude.Data.Text
was imported plainly like import Data.Text
, it'd only make Data.Text.null
available as null
and it'd be impossible to call because it clashes with Prelude.null
.(By the way, you don't need parens around (T.null oldNotes)
because if
is a keyword, not a function, and so Haskell can figure out unambiguously that T.null oldNotes
is the condition here.)
oldValue == T.empty
T.null oldValue
is the preferred version. Generally in Haskell you use pattern-matching, case
or predicates like null
and isNothing
when possible, though foo == "blah"
is still more acceptable than foo == ""
– this has to do with the fact that when you use foo == []
on lists in general, it works in less cases than null foo
(because e.g. you can't compare an [Int -> Int]
list with anything but you can still check whether it's empty or not). There are also other arguments here: http://stackoverflow.com/questions/3853922/null-instead-of.
Other than that, the table column for the empty old value still exists.
Can you fix this as well? It's not hard, you only need to conditionally execute the code that adds the table cell – e.g.
unless (T.null oldEcosystem) $
td_ $ blockquote_ $ toHtml (toMarkdownBlock oldEcosystem)
(Well, and check that CSS doesn't get broken when there's only one cell.)
Other than that, the table column for the empty old value still exists.
Can you fix this as well?
Done. :smile:
(Well, and check that CSS doesn't get broken when there's only one cell.)
The CSS did not break. In fact it looks the same as the case when you add a pro or a con. This is what it looks like:
Quick Fix to issue #96.
Text
type value is empty, the descriptive text uses the word "added" instead of "changed". Other than that, the table column for the empty old value still exists. (See image below for example) Let me know if empty value columns require removal. That will require some more ninja chops. :hocho:Edit'Set*
have been modified. The ones which have not been touched are those which either have default old values which are not empty ornull
; or have a default enumerated value assigned to them (system-defined orNothing
), at the time of creation.I am an absolute noob when it comes to Haskell.
if-then-else
construct was justified (it seems to get the desired effect).Data.Text
type object was empty, I referred to https://github.com/aelve/guide/blob/master/lib/View.hs#L62-L64 and onlyoldValue == T.empty
or(T.null oldValue)
seemed to work. I used the latter. (I don't fully understand whyoldValue == Text.empty
or(Text.null oldValue)
don't work. I'll leave that as is.)