
Research
PyPI Package Disguised as Instagram Growth Tool Harvests User Credentials
A deceptive PyPI package posing as an Instagram growth tool collects user credentials and sends them to third-party bot services.
Exploring monads from the illiterate perspective of a software engineer that has no clue about hardcore mathematics, functional programming or category theory.
At some point at work, I was introduced to Railway Oriented Programming 1 by a colleague that created an internal library to chain and beautifully create workflows or logic steps. Although descriptive enough, the simple difference between Bind()
and Map()
caught me unprepared and concerns were raised about how user friendly it would to OOP die-hard. We settled on predominantly having a Then()
method with overloads for when it acted as a bind
or map
, and I cannot stress enough how pleasant is to write code with it.
In parallel, I started to sporadically dabble into Rust and soon fell in love with the no such thing as null
feature and its Result
and Option
types, which after so many Object null exceptions
in csharp, it felt like a breeze of fresh air and paradoxically the right way to handle not having a value.
This project is an attempt to slowly understand functional programming concepts while at the same time implementing a utility library I'll be comfortable using. Focusing on practicality on C# rather that functional purism, this will aim to bridge the gap between engineering and theory providing familiar constructs for the c# connoisseur.
[!NOTE] This project
willmight not be exactly what a Category Theory/Monads expert expect. There is an excellent project, language-ext that basically brings almost all FP paradigms to c#. Nomads is a extremely low-fi version that looks to start as close as possible to C#, aiming to reduce "agnosiophobia" on the newcomers.
I think like everyone, I struggled (and still do) with the concept of Monads. Misspelling it is my tribute to that sensation of feeling dumb while it seems everyone with an article on Monads is enlighten with a divine secret.
Also, it sounds kinda cute.
Nomads provide implementations for the basic functional functors Option<T>
and Result<TValue, TError>
.
Static Constructors
using Nomads;
Option<string> someOption = Option.Some("Hi");
Option<string> noneOption = Option.None();
Result<string, int> okResult = Result.Ok("Ok");
Result<string, int> okResult = Result.Error(-1);
Adding a static using statement simplifies it (try global usings
!)
using Nomads;
using static Nomads.Option;
using static Nomads.Result;
Option<string> someOption = Some("Hi");
Option<string> noneOption = None();
Result<string, int> okResult = Ok("Ok");
Result<string, int> okResult = Error(-1);
Implicit casting
using Nomads;
using Nomads.Primitives;
Option<string> someOption = "Hi";
Option<string> noneOption = new None();
Result<string, int> okResult = "Ok";
Result<string, int> okResult = -1;
// For results where value and error are of the same type,
// specific Ok() or Error() primitives must be used.
Result<string, string> sameTypeOkResult = new Ok("Ok");
Result<string, string> sameTypeErrorResult = new Error("Err");
[!NOTE] Primitives
None
,Ok
andError
records are primarily used for easy implicit casting in cases types are ambiguous or aligns with user preferences.
Both Option
and Result
expose a public HasValue
property that can be queried to determine valid access to the (also public) Value
property.
Option<string> some = Option.Some("Hey");
string value = some.HasValue
? some.Value!
: "???";
Result<string, Exception> result = new Exception("I failed you");
string output = result.HasValue
? result.Value
: result.Error!.Message;
Optionally and for convenience, extension methods are provided.
Option<string> value = Option
.Some("Hey")
.ValueOrElse("???");
string result = Error<string, Exception>(new Exception("I failed you"))
.Match(
ok => ok,
err => err.Message
);
Both Option
and Result
functors can be "mapped" with function delegates using Select()
extension methods.
var option = Option
.Some("hi")
.Select(x => x.ToUpper());
Assert.Equal("HI", option.Value!);
var result = Result
.Ok("bye")
.Select(x => x.ToUpper());
Assert.Equal("BYE", result.Value!);
The word
Select
is used to defined what is commonly known in FP asmap
operation, beingSelect
is more akin to C# syntax.
This project is licensed with the MIT license.
FAQs
Unknown package
We found that nomads demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
A deceptive PyPI package posing as an Instagram growth tool collects user credentials and sends them to third-party bot services.
Product
Socket now supports pylock.toml, enabling secure, reproducible Python builds with advanced scanning and full alignment with PEP 751's new standard.
Security News
Research
Socket uncovered two npm packages that register hidden HTTP endpoints to delete all files on command.