Skip to content
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

Branch for review #1

Open
wants to merge 45 commits into
base: review-branch
Choose a base branch
from
Open

Branch for review #1

wants to merge 45 commits into from

Conversation

Hardes1
Copy link
Owner

@Hardes1 Hardes1 commented May 21, 2024

No description provided.

@kajigor
Copy link

kajigor commented May 25, 2024

The best word is not from the dictionary:

Screenshot 2024-05-25 at 10 36 15 PM

@kajigor
Copy link

kajigor commented May 25, 2024

Ah, I see this is intended behaviour

Comment on lines +11 to +15
getLaWordList = getWordList "res/la-dict.txt"


getTaWordList :: IO [String]
getTaWordList = getWordList "res/ta-dict.txt"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As in other languages, it's better to store the names of the files in a config

Comment on lines +11 to +12
show (WordParseError err word) = "Word '" <> word <> "'. " <> show err
show (UnknownCommand cmd) = "Unsupported command: '" <> cmd <> "'."
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here and everywhere else you want to concatenate strings, it's better to use prinf from Text.Printf. And in general, it's better to use Text

findBestWord searchDict inputDict =
let transformedWords = map (\candidate -> (candidate, getColorCountForDict candidate inputDict)) searchDict
h = head transformedWords
in if not $ null inputDict then Just $ fst $ foldl (\x y ->
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Funny enough, there is a notNull function

let transformedWords = map (\candidate -> (candidate, getColorCountForDict candidate inputDict)) searchDict
h = head transformedWords
in if not $ null inputDict then Just $ fst $ foldl (\x y ->
if compareWords x y == LT then y else x
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you provided an instance of Ord for the data type that represents the dictionaries, you could have then used minimum/maximum/sort and other useful standard library functions

let cnt = fst env
let lst = snd env
if ah == eh
then modify $ const (cnt, (Green, eh) : lst)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

modify . const is equivalent to put

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants