added lisp,idris,chef,befunge and changed perl a bit#66
added lisp,idris,chef,befunge and changed perl a bit#66shubhayu-dev wants to merge 1 commit intomanvith12:mainfrom
Conversation
Reviewer's GuideIntroduces a consistent polite-loop interaction by upgrading the Perl script and supplying equivalent implementations (or stubs) in multiple languages. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
WalkthroughAdds or updates multiple language files to implement a simple interactive “politeness” check: prompt user, read input, normalize case, check for the substring "please", and branch to print one of two fixed responses. Some implementations loop until polite input; others exit after a single branch. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor User
participant App as Program
rect rgb(245,248,255)
note right of App: Start interaction
User->>App: Input request
App->>User: "Say something:"
User-->>App: text
App->>App: normalize to lowercase
alt contains "please"
App-->>User: "Thank you for being polite. Still no."
note over App,User: End (some variants loop or exit)
else not polite
App-->>User: "I'm sorry, I can't assist with it... Try again."
App->>App: loop/restart (where implemented)
end
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
Pre-merge checks and finishing touches❌ Failed checks (1 inconclusive)
✅ Passed checks (2 passed)
✨ Finishing touches🧪 Generate unit tests
Tip 👮 Agentic pre-merge checks are now available in preview!Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.
Please see the documentation for more information. Example: reviews:
pre_merge_checks:
custom_checks:
- name: "Undocumented Breaking Changes"
mode: "warning"
instructions: |
Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).Please share your feedback with us on this Discord post. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Thank you for submitting your pull request! 🙌 We'll review it as soon as possible. In the meantime, please ensure that your changes align with our [CONTRIBUTING.md]. If there are any specific instructions or feedback regarding your PR, we'll provide them here. Thanks again for your contribution! 😊 |
There was a problem hiding this comment.
Hey there - I've reviewed your changes - here's some feedback:
- Remove or populate the empty Chef, Befunge, and SPL files instead of committing them as empty placeholders.
- Verify the Lisp and Idris snippets use the correct string search functions and imports (e.g.
string-containsin Lisp andtoLower/isInfixOfin Idris) so they actually compile. - In the Perl loop, handle EOF or undefined input (e.g. check if
<STDIN>returned undef) to avoid an infinite loop when input is closed.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Remove or populate the empty Chef, Befunge, and SPL files instead of committing them as empty placeholders.
- Verify the Lisp and Idris snippets use the correct string search functions and imports (e.g. `string-contains` in Lisp and `toLower`/`isInfixOf` in Idris) so they actually compile.
- In the Perl loop, handle EOF or undefined input (e.g. check if `<STDIN>` returned undef) to avoid an infinite loop when input is closed.
## Individual Comments
### Comment 1
<location> `Idris.idr:8-11` </location>
<code_context>
+politeLoop = do
+ putStr "Say something: "
+ input <- getLine
+ if "please" `isInfixOf` toLower input then
+ putStrLn "Thank you for being polite. Still no."
+ else do
</code_context>
<issue_to_address>
**suggestion:** Consider trimming whitespace from input before processing.
Trimming whitespace before converting to lowercase will help ensure consistent matching and avoid issues with user input.
```suggestion
input <- getLine
let cleanedInput = toLower (trim input)
if "please" `isInfixOf` cleanedInput then
putStrLn "Thank you for being polite. Still no."
else do
```
</issue_to_address>
### Comment 2
<location> `lsp.lisp:7` </location>
<code_context>
+ (if (string-contains input "please")
+ (display "Thank you for being polite. Still no.\n")
+ (begin
+ (display "I'm sorry, I can't assist with it. You weren't polite. Try again.\n")
+ (polite-loop)))))
+
</code_context>
<issue_to_address>
**suggestion:** Repeated prompt may be improved by clearing the line or adding spacing.
Frequent loop iterations can clutter the output. Add a blank line or clear the prompt to improve readability.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| input <- getLine | ||
| if "please" `isInfixOf` toLower input then | ||
| putStrLn "Thank you for being polite. Still no." | ||
| else do |
There was a problem hiding this comment.
suggestion: Consider trimming whitespace from input before processing.
Trimming whitespace before converting to lowercase will help ensure consistent matching and avoid issues with user input.
| input <- getLine | |
| if "please" `isInfixOf` toLower input then | |
| putStrLn "Thank you for being polite. Still no." | |
| else do | |
| input <- getLine | |
| let cleanedInput = toLower (trim input) | |
| if "please" `isInfixOf` cleanedInput then | |
| putStrLn "Thank you for being polite. Still no." | |
| else do |
| (if (string-contains input "please") | ||
| (display "Thank you for being polite. Still no.\n") | ||
| (begin | ||
| (display "I'm sorry, I can't assist with it. You weren't polite. Try again.\n") |
There was a problem hiding this comment.
suggestion: Repeated prompt may be improved by clearing the line or adding spacing.
Frequent loop iterations can clutter the output. Add a blank line or clear the prompt to improve readability.
There was a problem hiding this comment.
Actionable comments posted: 4
🧹 Nitpick comments (5)
Perl.pl (1)
6-6: Ensure prompt is visible immediately (autoflush or newline)Without a newline, the prompt may be buffered. Enable autoflush or print a trailing newline.
Add after
use warnings;:$| = 1; # autoflush STDOUTAlternatively, change the prompt to include
\n.Idris.idr (2)
7-7: Flush the prompt or print with newline
putStrwithout newline may buffer the prompt. PreferputStrLn.Apply this diff:
- putStr "Say something: " + putStrLn "Say something:"
5-13: Optional: Provide an entrypointIf this is meant to run standalone, add
main.Example:
main : IO () main = politeLoopSPL.spl (1)
1-12: Confirm intent: prose vs valid SPLAs written, this likely won’t compile as Shakespeare (e.g., string literals, conditionals, and I/O don’t follow SPL semantics). If illustrative prose is intended, all good; if executable SPL is desired, it needs rework (variables, addressing, “Speak your mind,” input verbs).
Happy to provide a compilable SPL version if you confirm the target interpreter.
Chef.chef (1)
7-13: Chef semantics checkStandard Chef doesn’t have direct string I/O or “contains” tests; “Serve” also varies by interpreter. If this is illustrative, fine; if you want an executable Chef program, it will need spec‑compliant steps (mixing bowl operations, baking dish, output).
I can adapt this to a form that runs under a common Chef interpreter—confirm which one you target.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
Befunge.bf93(1 hunks)Chef.chef(1 hunks)Idris.idr(1 hunks)Perl.pl(1 hunks)SPL.spl(1 hunks)lsp.lisp(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Sourcery review
| >:"eselpa"?v | ||
| >"Thank you for being polite. Still no."@ | ||
| ^"I'm sorry, I can't assist with it. You weren't polite. Try again."< |
There was a problem hiding this comment.
Program doesn’t read input and uses random branch
There’s no ~/& to read input, and ? introduces nondeterminism. Also, the pushed string is eselpa (not please reversed).
Would you like a minimal Befunge-93 version that actually prompts, reads a line, and checks for “please”?
| (display "Say something: ") | ||
| (let ((input (string-downcase (read-line)))) |
There was a problem hiding this comment.
Flush the prompt before waiting for input.
Without a newline or explicit flush, many Scheme implementations buffer the prompt, so the user never sees “Say something: ” before the program blocks on read-line.
Add an explicit flush:
(display "Say something: ")
+ (flush-output)🤖 Prompt for AI Agents
In lsp.lisp around lines 2–3, the prompt is displayed but not flushed before
read-line, so the prompt may not appear; insert an explicit output flush (e.g.
call the implementation's flush function immediately after the (display "Say
something: ") — or alternatively write a trailing newline and then flush) to
ensure the prompt is visible before blocking on (read-line).
| (if (string-contains input "please") | ||
| (display "Thank you for being polite. Still no.\n") |
There was a problem hiding this comment.
Fix the predicate name for the substring check.
string-contains is unresolved in standard Scheme/Racket; the available predicate is string-contains?. This currently raises an unbound identifier error, so the polite check never runs.
Apply this diff:
- (if (string-contains input "please")
+ (if (string-contains? input "please")📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| (if (string-contains input "please") | |
| (display "Thank you for being polite. Still no.\n") | |
| (if (string-contains? input "please") | |
| (display "Thank you for being polite. Still no.\n") |
🤖 Prompt for AI Agents
In lsp.lisp around lines 4 to 5, the code uses the non-existent predicate
`string-contains`; replace it with the correct Racket/Scheme predicate
`string-contains?` so the substring check binds and the polite branch runs
(ensure the call signature remains the same and update any other occurrences in
the file).
| my $user_input = <STDIN>; | ||
| chomp($user_input); | ||
| my $user_input_lower = lc($user_input); |
There was a problem hiding this comment.
Handle EOF to avoid infinite loop and warnings
On Ctrl-D/EOF, <STDIN> returns undef; chomp/lc will warn and the loop won’t exit.
Apply this diff:
- my $user_input = <STDIN>;
- chomp($user_input);
- my $user_input_lower = lc($user_input);
+ my $user_input = <STDIN>;
+ if (!defined $user_input) { print "\n"; last; }
+ chomp $user_input;
+ my $user_input_lower = lc $user_input;🤖 Prompt for AI Agents
In Perl.pl around lines 7 to 9, the code reads and processes STDIN without
handling EOF so Ctrl-D returns undef causing chomp/lc warnings and the loop not
to exit; change the read logic to check defined($user_input) immediately after
reading and exit the loop (last/return) when undef is returned, and only call
chomp and lc on a defined $user_input (or refactor to a while defined(my
$user_input = <STDIN>) { chomp $user_input; my $user_input_lower = lc
$user_input; ... }).
Summary by Sourcery
Implement a polite interaction loop across multiple languages that continuously prompts the user and only exits when the user includes “please” in their input.
New Features:
Summary by CodeRabbit