<commit_before>---
title: HappyPath.happyAttempt(Attempt&lt;Happy&gt;)
layout: post
---
[javadoc](https://oss.sonatype.org/service/local/repositories/releases/archive/io/github/theangrydev/business-flows/10.1.11/business-flows-10.1.11-javadoc.jar/!/io/github/theangrydev/businessflows/HappyPath.html#happyAttempt-io.github.theangrydev.businessflows.Attempt-) [usage tests](https://github.com/theangrydev/business-flows/blob/master/src/test/java/api/HappyAttemptApiTest.java)

Added in version 1.0.0

These tests exist to prevent the failed solution to <a href="https://github.com/theangrydev/business-flows/issues/12">#12</a>
from being attempted again in the future without realising it :)

## Happy attempt can introduce sad type via then
```java
Sad sad = new Sad();

HappyPath<Happy, Sad> happyPath = HappyPath.<Happy, Sad>happyAttempt(Happy::new)
    .then(happy -> HappyPath.sadPath(sad));

assertThat(happyPath.getSad()).isEqualTo(sad);<commit_msg>Updated documentation files for 10.1.12<commit_after>---
title: HappyPath.happyAttempt(Attempt&lt;Happy&gt;)
layout: post
---
[javadoc](https://oss.sonatype.org/service/local/repositories/releases/archive/io/github/theangrydev/business-flows/10.1.12/business-flows-10.1.12-javadoc.jar/!/io/github/theangrydev/businessflows/HappyPath.html#happyAttempt-io.github.theangrydev.businessflows.Attempt-) [usage tests](https://github.com/theangrydev/business-flows/blob/master/src/test/java/api/HappyAttemptApiTest.java)

Added in version 1.0.0

These tests exist to prevent the failed solution to <a href="https://github.com/theangrydev/business-flows/issues/12">#12</a>
from being attempted again in the future without realising it :)

## Happy attempt can introduce sad type via then
```java
Sad sad = new Sad();

HappyPath<Happy, Sad> happyPath = HappyPath.<Happy, Sad>happyAttempt(Happy::new)
    .then(happy -> HappyPath.sadPath(sad));

assertThat(happyPath.getSad()).isEqualTo(sad);
{'fraction_non_alphanumeric': 0.14772727272727273, 'fraction_numerical': 0.020144628099173553, 'mean_word_length': 5.610921501706485, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 13, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5387175', 'n_tokens_mistral': 708, 'n_tokens_neox': 638, 'n_words': 111}