Home | Notifications | New Note | Local | Federated | Search | Logout

Note Detail


Reply to @tembok@misskey.id
Layar Laut@layarlaut@misskey.id (2026-09-17 16:01:15)
@tembok when I write in Haskell I rarely run into that problem. You just coupled them as a single data representation with ADT. Seperate stuff between IO and pure function. Try looking up "functional core, imperative shell"

Though there's some places where FP is impossible because of how the architecture is written. For example, in most game engine require you to directly modify other objects. ECS architecture like bevy on the other hand require you to say upfront what data it needs and what data it modifies
---Reply--- tembok@tembok@misskey.id (2026-09-19 07:38:46) @layarlaut ohh til

Tbh I'm still confused on what's considered a pure function. Like in the resource that I use to learn about pure function, it says that suppose you have these functions:
func A() {
....
}

func B() {
....
A(....)
....
}

They said that func B is impure, and you should write it like this
func A() {
....
}

func B(A) {
....
A(....)
....
}

Isn't that just gonna make writing a function a hassle? Since you need to type every "dependency" into the parameter
Reply

---Replies---
Layar Laut@layarlaut@misskey.id (2026-09-19 09:06:48)
@tembok where do you read that? as long as A is pure. It's fine to directly call A inside B. 

And in the case A is impure and B needs some thing from A, the result of A is the one that should be passed along rather than A itself. Passing A would make B impure.

The only time you need to pass a function is when you need different functionality depending with the same structure or when you need dependency injection