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

Add usleep from System to Effect.System #3749

Merged
merged 3 commits into from
Apr 18, 2017

Conversation

artemohanjanyan
Copy link
Contributor

No description provided.

Copy link

@ahmadsalim ahmadsalim left a 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?

@@ -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))} ->

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.

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.

Copy link
Contributor Author

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?

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)).

@@ -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))} ->

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

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?

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`.
@ahmadsalim ahmadsalim merged commit 385f848 into idris-lang:master Apr 18, 2017
@ahmadsalim
Copy link

Thanks!

msmorgan pushed a commit to msmorgan/Idris-dev that referenced this pull request Aug 28, 2017
* Add usleep from System to Effect.System
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.

None yet

2 participants