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

[ refactor ] export signal to code conversions #3373

Merged
merged 3 commits into from
Aug 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG_NEXT.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,8 @@ This CHANGELOG describes the merged but unreleased changes. Please see [CHANGELO

* Added `fromRight` and `fromLeft` for extracting values out of `Either`, equivalent to `fromJust` for `Just`.

* Export `System.Signal.signalCode` and `System.Signal.toSignal`.

#### Contrib

* `Data.List.Lazy` was moved from `contrib` to `base`.
Expand Down
5 changes: 5 additions & 0 deletions libs/base/System/Signal.idr
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ Eq Signal where
SigPosix x == SigPosix y = x == y
_ == _ = False

||| Converts a `Signal` to its integer representation to be used
||| in FFI calls.
export
signalCode : Signal -> Int
signalCode SigINT = prim__sigint
signalCode SigABRT = prim__sigabrt
Expand All @@ -117,6 +120,8 @@ signalCode (SigPosix SigTRAP ) = prim__sigtrap
signalCode (SigPosix SigUser1) = prim__sigusr1
signalCode (SigPosix SigUser2) = prim__sigusr2

||| Tries to convert an integer to the corresponding `Signal`.
export
toSignal : Int -> Maybe Signal
toSignal (-1) = Nothing
toSignal x = lookup x codes
Expand Down