ultramagnetic

Lead Developer at Scott Logic by day, Architecturally curious, techno freak by night. Creator of Higher-Kinded-J higher-kinded-j.github.io
#higher-kinded-j #hkj #java #scala #clojure
Views are frequently my own

ultramagnetic boosted:
2025-06-29

Solving `UK Passport Application` with Haskell

Link: jameshaydon.github.io/passport
Discussion: news.ycombinator.com/item?id=4

#haskell #uk

2025-06-29

This is great analysis of AI hype/reality/motives of the pkayers and played

Original post: bsky.app/profile/did:plc:4kdpa

2025-06-12

Writing functional Java just got a whole lot cleaner. ✨
The new For-Comprehension builder in #higher-kinded-j helps de-sugar complex monadic chains into a simple, sequential script.
It brings the elegance of Scala to your functional Java projects.
Compose sequences of monadic operations (like flatMap and map) in a highly readable, linear style.
Key Features:
➡️ from(…): A generator that extracts a value from a monadic context (flatMap).
➡️ let(…): Binds the result of a pure computation to a new variable (map).
➡️ when(…): Filters results, short-circuiting with the monad's "zero" element (for MonadZero types like List or Maybe).
➡️ yield(…): Concludes the comprehension, producing the final monadic value.
It's especially powerful for taming complex structures like monad transformers (StateT, EitherT).
Come see how it works! Any feedback is welcome. [higher-kinded-j.github.io/for_]
#Java #FunctionalProgramming #FP #Monad #HKT #Library #OpenSource #HKJ

ultramagnetic boosted:
Arjen Poutsmapoutsma
2025-06-11

New post: Making Your API Feel Like Home
If your API looks & feels like the rest of the ecosystem, it is easier to learn and harder to misuse.

poutsma-principles.com/blog/20

2025-06-06

Learn how to use the State monad and IO monad in #Java with higher-kinded types by building a playable Draughts game with the new #higher-kinded-j functional library. #fp #functional #monad #hkj higher-kinded-j.github.io/drau

2025-06-05

Higher-Kinded-J is a new functional library for #Java bringing higher-kinded types to popular monad patterns. higher-kinded-j.github.io

2025-05-11

@ethauvin Probably some outdated commandment from when java could only catch a single exception type in a try.

2025-05-11

@froufox @ultramagnetic I blogged on phantom types a little while back if you want another example techhub.social/@ultramagnetic/

2025-05-11

@froufox @ultramagnetic Say we have a DocHandler type that goes through review DocStates, New, Draft, Reviewed, etc. Where certain operations are allowed. These are empty interfaces aka Phantom types. We have a DocHandler<D extends DocState>. We have a DocHandler private constructor and factory methods like create initialise a DocHandler in the New DocState by returning DocHandler<New>. Transitioning methods like
DocHandler<Draft> draft(DocHandler<New> doc){
// call helper class to do work
return (DocHandler<Draft>)doc;
} and
DocHandler<Reviewed> review(DocHandler<Draft> doc){
// call helper to do work
return (DocHandler<Reviewed>)doc;
}
This approach gives us a type safe gate keeper to the helper class dependent on the phantom type. The casting is all safe as they dont change runtime structure only how the compiler validates. The raw underlying type is unchanged and no runtime overhead.

2025-05-10

Phantom types are an under appreciated feature in #Java. Can simulate typestate programming where an objects type changes to reflect current state, with operations available on that object depending on its current typestate. We can parametrise this using a base type and phantom type.

2025-05-02

In my latest post we explore how to manage deep recursion in Java and Scala using thunks and trampolines. Learn techniques that help avoid stack overflows and make recursive code more efficient. #Java #Scala #FunctionalProgramming
blog.scottlogic.com/2025/05/02

2025-04-17

@elricofmelnibone @ultramagnetic Yeah exactly the eternal struggle between too much magic vs too much boiler plate.

2025-04-17

@elricofmelnibone
Thanks so much for your feedback and encouragement!

I take your point about parsing the type signatures. Its perhaps more subjective than i credited. certainly familiarity is a big factor. From what I understand reading so far valhalla could certainly help with boxing and allocation overhead.

You have me thinking. Perhaps a much more compelling Java example could be a multi-step business process involving different contexts. I had an idea of an order processing example where execution details could include validation, sync/async io, error handling, side effects and testing with a mock context.

I agree this could indeed be a fun little project to build this out into a library with the goal of supporting more compelling Java examples. I'm also keen to try and see if some of the boiler plate could perhaps be better handled with annotations.

I'm thinking a follow up blog post might be brewing soon! 🙂

2025-04-11

Higher-kinded types provide abstractions allowing us to define operations once and reuse across many different data structures. In my latest post i explore how they work in #Scala and how we can simulate them ourselves using #Java blog.scottlogic.com/2025/04/11

ultramagnetic boosted:
Lisp & Scheme Weeklylisp_discussions
2025-04-10
2025-04-01

My latest blog post covering how we can write cleaner, more composable and robust code using functors and monads with examples in #java and #scala blog.scottlogic.com/2025/03/31

2025-03-05

In this third post in a series looking at types and type sytems we explore Intersection and Union types with the latest #java and #scala. blog.scottlogic.com/2025/03/05

2025-03-05

In this third post in a series looking at types and type sytems we explore Intersection and Union types with the latest #java and #scala. We compare and contrast approaches looking at flexibility and reuse. blog.scottlogic.com/2025/03/05

2025-02-18

@ppurang @ultramagnetic Thanks thats really interesting. I'll update the post. I'm hoping to cover path dependent types in the future. I need to think of a good short example

2025-02-17

My latest blogpost covering Variance in generics, Phantom and Existential types with #Java and #Scala blog.scottlogic.com/2025/02/17

Client Info

Server: https://mastodon.social
Version: 2025.04
Repository: https://github.com/cyevgeniy/lmst