---
title: "Discussion on \"Extending Kotlin's Null-Safety with Monad Comprehension\" | Hashnode"
description: "Discussion on \"Extending Kotlin's Null-Safety with Monad Comprehension\". Kotlin has a very decent null-safety baked in; and even better, it is a part of its type system.\n\nprivate fun easy1(str: String?): String {\n    return str?.let {\n        return \"$str is so easy\"\n    } ?: \"Not so easy after all\"\n}\n\n// We can easily ca..."
url: "https://hashnode.com/posts/extending-kotlins-null-safety-with-monad-comprehension/65f73c77684cee4498a73d43"
---

[Feed](https://hashnode.com/feed) /

Discussion

[Ikechukwu Eze](https://hashnode.com/@Ikezedev)

Software Engineer @Cognite

Mar 17, 2024

# [Extending Kotlin's Null-Safety with Monad Comprehension](https://blog.ikeze.dev/extending-kotlins-null-safety-with-monad-comprehension?utm_source=hashnode&utm_medium=feed)

Kotlin has a very decent null-safety baked in; and even better, it is a part of its type system. private fun easy1(str: String?): String { return str?.let { return "$str is so easy" } ?: "Not so easy after all" } // We can easily ca...

blog.ikeze.dev 9 min read

[#kotlin](https://hashnode.com/tag/kotlin) [#monad](https://hashnode.com/tag/monad) [#functional-programming](https://hashnode.com/tag/functional-programming) [#null-safety](https://hashnode.com/tag/null-safety)

## Responses 1

Markdown supported · ⌘↵ to post

[Ryan Hintze](https://hashnode.com/@spyderrsh)

Android Software Engineer. Lover of Kotlin.

[Mar 18, 2024](https://hashnode.com/posts/extending-kotlins-null-safety-with-monad-comprehension/65f73c77684cee4498a73d43/comment/65f86e358b3ed7f936c93daf)

Enjoyed the article! What do you think of using contracts for nullable values instead of using the result of `bind`? I can only think that this might cause some issues if a background thread or value read changes the value. I implemented a PoC here:

https:// github .com/spyderrsh/extending-kotlin-null-safetly/commit/40fc29336725f2e4c7fdd353c062973405a356a6

(Sorry, new user, so I had to add spaces in my link)
