-
Notifications
You must be signed in to change notification settings - Fork 642
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
Add usleep from System to Effect.System #3749
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! I have added some suggestions regarding things that could improve. Could you kindly take a look at this and also add a note in the CHANGELOG
?
libs/effects/Effect/System.idr
Outdated
@@ -14,18 +15,23 @@ data System : Effect where | |||
Time : sig System Integer | |||
GetEnv : String -> sig System (Maybe String) | |||
CSystem : String -> sig System Int | |||
Usleep : (i : Int) -> | |||
{auto prf : So (i >= fromInteger 0 && Delay (i <= fromInteger 1000000))} -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason you use fromInteger
here explicitly? literals should be overloaded. The same with Delay
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also I would in the constructor probably not use auto
, only in the external signature used by the user.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just copied the type from System.usleep
. fromInteger
is probably not necessary, it's shown when you type :t usleep
in REPL, but it's not present in the source file. However, auto
is used in that source file. Should I still remove it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@artemohanjanyan Yeah, so I am not sure it is necessary for a constructor to have it. I would just take an argument (inbounds : So (i >= 0 && i <= 1000000))
.
libs/effects/Effect/System.idr
Outdated
@@ -43,3 +49,8 @@ getEnv s = call $ GetEnv s | |||
|
|||
system : String -> Eff Int [SYSTEM] | |||
system s = call $ CSystem s | |||
|
|||
usleep : (i : Int) -> | |||
{auto prf : So (i >= fromInteger 0 && Delay (i <= fromInteger 1000000))} -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment regarding the use of fromInteger
and Delay
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any reason you do not use System.usleep
here instead of copying it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I missed that this calls the effect, whose handler uses the system one.
Unnecessary `fromInteger` and `Delay` were removed. `prf` is now explicit argument of type constructor, but it's still implicit in function as in `System.usleep`.
Thanks! |
* Add usleep from System to Effect.System
No description provided.