Commit Graph

33 Commits

Author SHA1 Message Date
Keagan McClelland
eaa5e4a039
fn: remove redundant Reduce function
This commit removes Reduce since we already have both Foldl and Foldr.
2024-07-10 17:06:09 -07:00
Keagan McClelland
fa2e25d5f4
fn: remove lru dependency 2024-07-10 17:06:04 -07:00
Keagan McClelland
364d79e552
fn: add generic version of List 2024-07-10 16:55:29 -07:00
Keagan McClelland
fb1437cb6d
fn: add Elem function for set membership 2024-07-10 15:37:27 -07:00
Keagan McClelland
9c30bce10c
fn: add curried (in)equality functions 2024-07-10 15:37:27 -07:00
Keagan McClelland
c4df2f1dce
fn: reimplement internals of either, add tests 2024-07-10 15:37:27 -07:00
Keagan McClelland
1dd56f1b2a
fn: fix and finish the either API 2024-07-10 15:37:27 -07:00
Keagan McClelland
c3603ccf96
fn: add FindIdx function 2024-07-10 15:34:57 -07:00
Keagan McClelland
5902aa5159
fn: add concurrent map operation for slices 2024-07-10 15:29:16 -07:00
Keagan McClelland
94acbe90a8
fn: add fundamental functional primitives 2024-07-10 14:42:11 -07:00
Olaoluwa Osuntokun
f1a38714d4
fn: add additional utility methods for Result[T]
`NewResult` makes it easy to wrap a normal function call in a result
value.

`Err` can be used to check the error case of the result without
unpacking the entire thing.

`AndThen2` allows a caller to compose a function on two results values,
with the closure only executing if both values are non-error.
2024-06-20 15:05:28 -07:00
Keagan McClelland
cd3c17e1c0 fn: add predicate combinators for && and || 2024-06-03 12:24:02 -07:00
Oliver Gugger
c95505db1e
fn: add Result type
In this commit, we add a new result type, which is just Either[A, error]. This is useful as we can always pass around/accept a single value. We add an Unpack() method which is the most idiomatic way of handling errors in Go, as we revert back to (A, error) when necessary.
2024-05-29 09:39:39 +02:00
Ononiwu Maureen
95016b849a
fn: Added HasDuplicates function to slice
Signed-off-by: Ononiwu Maureen <59079323+Chinwendu20@users.noreply.github.com>
2024-05-20 11:54:33 +01:00
Ononiwu Maureen
30c9b86d62
fn: Added new slice functions.
Signed-off-by: Ononiwu Maureen <59079323+Chinwendu20@users.noreply.github.com>
2024-05-10 10:06:24 +01:00
Ononiwu Maureen
f88f120e91
fn: Added map functions
Signed-off-by: Ononiwu Maureen <59079323+Chinwendu20@users.noreply.github.com>
2024-05-10 09:55:16 +01:00
Oliver Gugger
4f06f58791
Merge pull request #8483 from ProofOfKeags/feature/for-loop-destroyer
fn: add slice utilities
2024-03-08 01:48:38 -06:00
Keagan McClelland
2bd9911804 fn: add slice utilities
In the year of our lord 2024 we should not be writing for loops
for standard operations. Here we introduce named slice operations
not found in the golang slices package. Note all these functions
are pure.
2024-03-02 11:43:07 -08:00
Olaoluwa Osuntokun
166b2fdb97 fn: add UnwrapOrErr and UnwrapOrFail to Option
In this commit, we add two new methods that simplify usage of an
handling a value wrapped in an Option. Thes methods allow a caller to
force the nil/None check up front, and either obtain the value, or fail
the current execution or test.

This should replace most usages of `UnsafeFromSome` where ever used
today.
2024-02-24 17:21:37 -08:00
Olaoluwa Osuntokun
1d1c1382d0
fn: add utility funcs/method for option type 2024-01-23 19:09:59 -08:00
Olaoluwa Osuntokun
1fc3f14467
fn: add new generic set container 2024-01-23 19:09:53 -08:00
Olaoluwa Osuntokun
eb72bb9712
fn: add SendOrQuit 2024-01-23 19:09:50 -08:00
Olaoluwa Osuntokun
a2694009cd
fn: add basic generic chan recv utility funcs 2024-01-23 19:09:47 -08:00
Olaoluwa Osuntokun
f7e2e6ddd6
fn: add basic generic queue 2024-01-23 19:09:45 -08:00
Olaoluwa Osuntokun
f166829fe4
fn: add reduce func 2024-01-23 19:09:42 -08:00
Olaoluwa Osuntokun
d702158d9b
fn: add new EventPublisher event pub/sub system
This builds on the concurrent queue to create a generic way to allow
goroutines to pub/sub information. An example includes being notified
each time a state machine is able to carry out a new state transition.
2024-01-23 19:09:39 -08:00
Olaoluwa Osuntokun
1cbfda525a
fn: add new Either[L, R] type
This implements a union of two values. Uses the existing option under
the hood, and adds a simple helper function.
2024-01-23 19:09:36 -08:00
Olaoluwa Osuntokun
0715e84f04
fn: add new ConcurrentQueue[T] data structure
This is a version of the queue we have elsewhere, but we can get rid of
all the casting and interface usage in favor of a type param.
2024-01-23 19:09:29 -08:00
Keagan McClelland
2499813414 fn: add UnsafeFromSome to Option API 2024-01-11 16:40:48 -08:00
Olaoluwa Osuntokun
b0114efad3
fn: create new sub-module
In this commit, we make a new sub-module from the `fn` package. This
lets other projects use it w/o pulling in all of lnd, and also other
sub-packages within lnd.

We also add a temp replace directive for new module.  We'll remove this
once we tag the final version.
2023-12-06 17:00:10 -08:00
Keagan McClelland
b298c84d21 fn: introduce option type
this commit introduces many of the most common functions you will
want to use with the Option type. Not all of them are used
immediately in this PR.
2023-11-10 13:29:30 -08:00
yyforyongyu
89b0e25e2c
multi: add lnutils to host fundamental utility functions
We also move the `fn/stream.go` into the package `lnutils`. Eventually
we will put all the [utility
functions](https://github.com/lightninglabs/taro/tree/main/chanutils)
into this package.
2023-01-19 06:38:50 +08:00
Olaoluwa Osuntokun
adb239300f
fn: add new fn (func utils) package for generic helper funcs
We start with a simple Map function that can be useful for transforming
objects on the fly.

We may want to eventually make this Taro pakage into a module so we can
just have everything in one place:
https://github.com/lightninglabs/taro/tree/main/chanutils.
2022-12-15 11:56:31 -08:00