diff --git a/messages/uniworx/de.msg b/messages/uniworx/de.msg index 69a48ab45..f426e0568 100644 --- a/messages/uniworx/de.msg +++ b/messages/uniworx/de.msg @@ -316,9 +316,9 @@ Correctors: Korrektoren CorState: Status CorByTut: Zuteilung nach Tutorium CorProportion: Anteil -CorByProportionOnly proportion@Rational: #{display proportion} Anteile -CorByProportionIncludingTutorial proportion@Rational: #{display proportion} Anteile - Tutorium -CorByProportionExcludingTutorial proportion@Rational: #{display proportion} Anteile + Tutorium +CorByProportionOnly proportion@Rational: #{rationalToFixed3 proportion} Anteile +CorByProportionIncludingTutorial proportion@Rational: #{rationalToFixed3 proportion} Anteile - Tutorium +CorByProportionExcludingTutorial proportion@Rational: #{rationalToFixed3 proportion} Anteile + Tutorium RowCount count@Int64: #{count} #{pluralDE count "passender Eintrag" "passende Einträge"} insgesamt DeleteRow: Entfernen diff --git a/src/Foundation.hs b/src/Foundation.hs index 7261724ef..ba7747040 100644 --- a/src/Foundation.hs +++ b/src/Foundation.hs @@ -350,6 +350,12 @@ instance HasResolution a => ToMessage (Fixed a) where toMessage = toMessage . showFixed True +-- Do not use toMessage on Rationals and round them automatically. Instead, use rationalToFixed3 (declared in src/Utils.hs) to convert a Rational to Fixed E3! +-- instance ToMessage Rational where +-- toMessage = toMessage . fromRational' +-- where fromRational' = fromRational :: Rational -> Fixed E3 + + newtype ErrorResponseTitle = ErrorResponseTitle ErrorResponse embedRenderMessageVariant ''UniWorX ''ErrorResponseTitle ("ErrorResponseTitle" <>) diff --git a/src/Model/Types/Common.hs b/src/Model/Types/Common.hs index 5ffbcfb07..674bb78f6 100644 --- a/src/Model/Types/Common.hs +++ b/src/Model/Types/Common.hs @@ -16,7 +16,6 @@ import qualified Yesod.Auth.Util.PasswordStore as PWStore type Count = Sum Integer type Points = Centi - type Email = Text type SchoolName = CI Text @@ -32,4 +31,4 @@ type PWHashAlgorithm = ByteString -> PWStore.Salt -> Int -> ByteString type InstanceId = UUID type ClusterId = UUID type TokenId = UUID -type TermCandidateIncidence = UUID +type TermCandidateIncidence = UUID \ No newline at end of file diff --git a/src/Utils.hs b/src/Utils.hs index e9949b8d9..66fe2b006 100644 --- a/src/Utils.hs +++ b/src/Utils.hs @@ -30,7 +30,6 @@ import Text.Blaze (Markup, ToMarkup) import Data.Char (isDigit, isSpace, isAscii) import Data.Text (dropWhileEnd, takeWhileEnd, justifyRight) -import Numeric (showFFloat) import Data.Set (Set) import qualified Data.Set as Set @@ -248,21 +247,8 @@ class DisplayAble a where default display :: Show a => a -> Text display = pack . show -instance DisplayAble Rational where - display r = showFFloat (Just 2) (rat2float r) "" - & pack - & dropWhileEnd ('0'==) - & dropWhileEnd ('.'==) - where - rat2float :: Rational -> Double - rat2float = fromRational - -{- We do not want DisplayAble for every Show-Class: - We want to explicitly verify that the resulting text can be displayed to the User! - For example: UTCTime values were shown without proper format rendering! -instance {-# OVERLAPPABLE #-} Show a => DisplayAble a where -- The easy way out of UndecidableInstances (TypeFamilies would have been proper, but are much more complicated) - display = pack . show --} +rationalToFixed3 :: Rational -> Fixed E3 +rationalToFixed3 = fromRational textPercent :: Real a => a -> Text -- slow, maybe use Data.Double.Conversion.Text.toFixed instead? textPercent x = lz <> pack (show rx) <> "%"