<commit_before>module Andon.Types where

import Text.Read
import Data.Text

-- | OrdInt 1 = 1st, OrdInt 2 = 2nd ...
newtype OrdInt = OrdInt
    { getInt :: Int
    } deriving (Eq, Ord)

instance Show OrdInt where
    show (OrdInt n) = case n `mod` 10 of
        1 -> show n ++ "st"
        2 -> show n ++ "nd"
        3 -> show n ++ "rd"
        _ -> show n ++ "th"

instance Read OrdInt where
    readPrec = parens $ do
        Int n <- lexP
        case n `mod` 10 of
            1 -> do
                Ident "st" <- lexP
                returnOrdInt n
            2 -> do
                Ident "nd" <- lexP
                returnOrdInt n
            3 -> do
                Ident "rd" <- lexP
                returnOrdInt n
            _ -> do
                Ident "th" <- lexP
                returnOrdInt n
      where
        returnOrdInt = return . OrdInt . fromInteger
    readListPrec = readListPrecDefault

data Prize = Grand
           | Gold
           | Silver
           | Bronze
           | None
           deriving (Show, Read, Eq)
                    
data Class = Class
    { getTimes :: OrdInt
    , getGrade :: Int
    , getClass :: Int
    , getTitle :: Text
    , getPrize :: Prize
    } 

instance Eq Class where
    c1 == c2 = getTimes c1 == getTimes c2 &&
               getGrade c1 == getGrade c2 &&
               getClass c1 == getClass c2
<commit_msg>modify (getPrize :: Prize) to (getPrize :: Maybe Prize)<commit_after>module Andon.Types where

import Text.Read
import Data.Text

-- | OrdInt 1 = 1st, OrdInt 2 = 2nd ...
newtype OrdInt = OrdInt
    { getInt :: Int
    } deriving (Eq, Ord)

instance Show OrdInt where
    show (OrdInt n) = case n `mod` 10 of
        1 -> show n ++ "st"
        2 -> show n ++ "nd"
        3 -> show n ++ "rd"
        _ -> show n ++ "th"

instance Read OrdInt where
    readPrec = parens $ do
        Int n <- lexP
        case n `mod` 10 of
            1 -> do
                Ident "st" <- lexP
                returnOrdInt n
            2 -> do
                Ident "nd" <- lexP
                returnOrdInt n
            3 -> do
                Ident "rd" <- lexP
                returnOrdInt n
            _ -> do
                Ident "th" <- lexP
                returnOrdInt n
      where
        returnOrdInt = return . OrdInt . fromInteger
    readListPrec = readListPrecDefault

data Prize = Grand
           | Gold
           | Silver
           | Bronze
           deriving (Show, Read, Eq)
                    
data Class = Class
    { getTimes :: OrdInt
    , getGrade :: Int
    , getClass :: Int
    , getTitle :: Text
    , getPrize :: Maybe Prize
    } 

instance Eq Class where
    c1 == c2 = getTimes c1 == getTimes c2 &&
               getGrade c1 == getGrade c2 &&
               getClass c1 == getClass c2

{'fraction_non_alphanumeric': 0.0919170243204578, 'fraction_numerical': 0.015736766809728183, 'mean_word_length': 1.2611156022635408, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2917084', 'n_tokens_mistral': 883, 'n_tokens_neox': 809, 'n_words': 284}