Handling nested Maybe monad inside Future










0















I'm still getting the hang of Functional Programming and am trying to figure out a bit of a curly issue with Monads. I have a situation where I have a future that makes an HTTP request and returns a list of values, for argument's sake. I then want to be able to check that a particular value exists in that list, I would have thought returning a Maybe monad here would be the win. But then if that value is present I want to be able to make another HTTP request based on that returned value but it should only run if that value exists. Here's an example that uses ramda-fantasy implementations of Future & Maybe https://codesandbox.io/s/2xvy3m1qmy



I'm quite possibly getting this whole thing wrong, so if you need more info, or need to change any of the above, go for it. Just to clarify this would be my workflow in pseudo code:



  1. Make a request for all values

  2. filter values and maybe find one that matches

  3. if found, make a request to get the rest of that data

Here's an initial, commented attempt, as linked above:



import R from "ramda";
import Fantasy from "ramda-fantasy";
const Future = Fantasy.Future;
const Maybe = Fantasy.Maybe;

// make a fake HTTP request and return a list of values
// response :: Future Array String
const response = Future.of(['one', 'two', 'three'])

const maybeOrNothing = val => val ? Maybe.Just(val) : Maybe.Nothing()

// Maybe return our given value
// getVal :: String -> Maybe String
const getVal = input => response.map(R.find(R.equals(input))).map(maybeOrNothing)

// make another fake request
// let's pretend that this takes an ID and makes a fake ajax request to get teh data
// getValueData :: String -> Future
const getValueData = id => Future((reject, resolve) =>
// fake HTTP request
setTimeout(() =>
resolve(
id: id,
foo: 'bar'
)
, 100)
)

// 'one' should then run getValueData
// something isn't right here, do I need to map then chain?
getVal('one')
.chain(getValueData)
.fork(console.error, console.log)

// 'five' isn't there, so shouldn't run getValueData
// something isn't right here as getValueData still runs
// map(R.chain) works to not run getValueData but then it causes issues later on
getVal('five')
.chain(getValueData)
.fork(console.error, console.log)









share|improve this question



















  • 1





    Please post the code itself in your question, not just a link to it.

    – Bergi
    Nov 12 '18 at 19:53











  • updated to include code in the post

    – Matt Sanders
    Nov 12 '18 at 22:16











  • getVal should have the type String -> Future (Maybe String), right?

    – Bergi
    Nov 13 '18 at 19:38















0















I'm still getting the hang of Functional Programming and am trying to figure out a bit of a curly issue with Monads. I have a situation where I have a future that makes an HTTP request and returns a list of values, for argument's sake. I then want to be able to check that a particular value exists in that list, I would have thought returning a Maybe monad here would be the win. But then if that value is present I want to be able to make another HTTP request based on that returned value but it should only run if that value exists. Here's an example that uses ramda-fantasy implementations of Future & Maybe https://codesandbox.io/s/2xvy3m1qmy



I'm quite possibly getting this whole thing wrong, so if you need more info, or need to change any of the above, go for it. Just to clarify this would be my workflow in pseudo code:



  1. Make a request for all values

  2. filter values and maybe find one that matches

  3. if found, make a request to get the rest of that data

Here's an initial, commented attempt, as linked above:



import R from "ramda";
import Fantasy from "ramda-fantasy";
const Future = Fantasy.Future;
const Maybe = Fantasy.Maybe;

// make a fake HTTP request and return a list of values
// response :: Future Array String
const response = Future.of(['one', 'two', 'three'])

const maybeOrNothing = val => val ? Maybe.Just(val) : Maybe.Nothing()

// Maybe return our given value
// getVal :: String -> Maybe String
const getVal = input => response.map(R.find(R.equals(input))).map(maybeOrNothing)

// make another fake request
// let's pretend that this takes an ID and makes a fake ajax request to get teh data
// getValueData :: String -> Future
const getValueData = id => Future((reject, resolve) =>
// fake HTTP request
setTimeout(() =>
resolve(
id: id,
foo: 'bar'
)
, 100)
)

// 'one' should then run getValueData
// something isn't right here, do I need to map then chain?
getVal('one')
.chain(getValueData)
.fork(console.error, console.log)

// 'five' isn't there, so shouldn't run getValueData
// something isn't right here as getValueData still runs
// map(R.chain) works to not run getValueData but then it causes issues later on
getVal('five')
.chain(getValueData)
.fork(console.error, console.log)









share|improve this question



















  • 1





    Please post the code itself in your question, not just a link to it.

    – Bergi
    Nov 12 '18 at 19:53











  • updated to include code in the post

    – Matt Sanders
    Nov 12 '18 at 22:16











  • getVal should have the type String -> Future (Maybe String), right?

    – Bergi
    Nov 13 '18 at 19:38













0












0








0








I'm still getting the hang of Functional Programming and am trying to figure out a bit of a curly issue with Monads. I have a situation where I have a future that makes an HTTP request and returns a list of values, for argument's sake. I then want to be able to check that a particular value exists in that list, I would have thought returning a Maybe monad here would be the win. But then if that value is present I want to be able to make another HTTP request based on that returned value but it should only run if that value exists. Here's an example that uses ramda-fantasy implementations of Future & Maybe https://codesandbox.io/s/2xvy3m1qmy



I'm quite possibly getting this whole thing wrong, so if you need more info, or need to change any of the above, go for it. Just to clarify this would be my workflow in pseudo code:



  1. Make a request for all values

  2. filter values and maybe find one that matches

  3. if found, make a request to get the rest of that data

Here's an initial, commented attempt, as linked above:



import R from "ramda";
import Fantasy from "ramda-fantasy";
const Future = Fantasy.Future;
const Maybe = Fantasy.Maybe;

// make a fake HTTP request and return a list of values
// response :: Future Array String
const response = Future.of(['one', 'two', 'three'])

const maybeOrNothing = val => val ? Maybe.Just(val) : Maybe.Nothing()

// Maybe return our given value
// getVal :: String -> Maybe String
const getVal = input => response.map(R.find(R.equals(input))).map(maybeOrNothing)

// make another fake request
// let's pretend that this takes an ID and makes a fake ajax request to get teh data
// getValueData :: String -> Future
const getValueData = id => Future((reject, resolve) =>
// fake HTTP request
setTimeout(() =>
resolve(
id: id,
foo: 'bar'
)
, 100)
)

// 'one' should then run getValueData
// something isn't right here, do I need to map then chain?
getVal('one')
.chain(getValueData)
.fork(console.error, console.log)

// 'five' isn't there, so shouldn't run getValueData
// something isn't right here as getValueData still runs
// map(R.chain) works to not run getValueData but then it causes issues later on
getVal('five')
.chain(getValueData)
.fork(console.error, console.log)









share|improve this question
















I'm still getting the hang of Functional Programming and am trying to figure out a bit of a curly issue with Monads. I have a situation where I have a future that makes an HTTP request and returns a list of values, for argument's sake. I then want to be able to check that a particular value exists in that list, I would have thought returning a Maybe monad here would be the win. But then if that value is present I want to be able to make another HTTP request based on that returned value but it should only run if that value exists. Here's an example that uses ramda-fantasy implementations of Future & Maybe https://codesandbox.io/s/2xvy3m1qmy



I'm quite possibly getting this whole thing wrong, so if you need more info, or need to change any of the above, go for it. Just to clarify this would be my workflow in pseudo code:



  1. Make a request for all values

  2. filter values and maybe find one that matches

  3. if found, make a request to get the rest of that data

Here's an initial, commented attempt, as linked above:



import R from "ramda";
import Fantasy from "ramda-fantasy";
const Future = Fantasy.Future;
const Maybe = Fantasy.Maybe;

// make a fake HTTP request and return a list of values
// response :: Future Array String
const response = Future.of(['one', 'two', 'three'])

const maybeOrNothing = val => val ? Maybe.Just(val) : Maybe.Nothing()

// Maybe return our given value
// getVal :: String -> Maybe String
const getVal = input => response.map(R.find(R.equals(input))).map(maybeOrNothing)

// make another fake request
// let's pretend that this takes an ID and makes a fake ajax request to get teh data
// getValueData :: String -> Future
const getValueData = id => Future((reject, resolve) =>
// fake HTTP request
setTimeout(() =>
resolve(
id: id,
foo: 'bar'
)
, 100)
)

// 'one' should then run getValueData
// something isn't right here, do I need to map then chain?
getVal('one')
.chain(getValueData)
.fork(console.error, console.log)

// 'five' isn't there, so shouldn't run getValueData
// something isn't right here as getValueData still runs
// map(R.chain) works to not run getValueData but then it causes issues later on
getVal('five')
.chain(getValueData)
.fork(console.error, console.log)






javascript functional-programming monads






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 12 '18 at 22:15







Matt Sanders

















asked Nov 12 '18 at 19:41









Matt SandersMatt Sanders

1169




1169







  • 1





    Please post the code itself in your question, not just a link to it.

    – Bergi
    Nov 12 '18 at 19:53











  • updated to include code in the post

    – Matt Sanders
    Nov 12 '18 at 22:16











  • getVal should have the type String -> Future (Maybe String), right?

    – Bergi
    Nov 13 '18 at 19:38












  • 1





    Please post the code itself in your question, not just a link to it.

    – Bergi
    Nov 12 '18 at 19:53











  • updated to include code in the post

    – Matt Sanders
    Nov 12 '18 at 22:16











  • getVal should have the type String -> Future (Maybe String), right?

    – Bergi
    Nov 13 '18 at 19:38







1




1





Please post the code itself in your question, not just a link to it.

– Bergi
Nov 12 '18 at 19:53





Please post the code itself in your question, not just a link to it.

– Bergi
Nov 12 '18 at 19:53













updated to include code in the post

– Matt Sanders
Nov 12 '18 at 22:16





updated to include code in the post

– Matt Sanders
Nov 12 '18 at 22:16













getVal should have the type String -> Future (Maybe String), right?

– Bergi
Nov 13 '18 at 19:38





getVal should have the type String -> Future (Maybe String), right?

– Bergi
Nov 13 '18 at 19:38












2 Answers
2






active

oldest

votes


















0














You must be looking for the sequence operations that could turn the Maybe<Future<…>> into a Future<Maybe<…>> which you can then join into your outer future.



With traverse:



getVal('one')
.chain(traverse(Future.of, getValueData))
.fork(console.error, console.log)





share|improve this answer























  • Hey Bergi, thanks for the response, that example didn't quite work. care to elaborate further?

    – Matt Sanders
    Nov 12 '18 at 22:50











  • It definitely should work, however traverse always seems to assume a list type not a Maybe. I don't know why, you might want to file a Ramda bug.

    – Bergi
    Nov 13 '18 at 19:52


















0














Managed to solve my own problem, partially because of Bergi's suggestion. Bergi's answer above was very close, but the implementation wasn't quite right. The issue was that I was trying to deal with a Future and then change it to a Maybe, so I dealt with it with the following:



import R from "ramda";
import Fantasy from "ramda-fantasy";
const Future = Fantasy.Future;
const Maybe = Fantasy.Maybe;

// make a fake HTTP request and return a list of values
// response :: Future Array String
const response = Future.of(['one', 'two', 'three'])

const maybeOrNothing = val => val ? Maybe.Just(val) : Maybe.Nothing()
const maybeToFuture = m => Maybe.isNothing(m) ? Future.reject() : Future.of(m.value)

// Maybe return our given value
// getVal :: String -> Maybe String
const getVal = input => response.map(R.find(R.equals(input))).map(maybeOrNothing)

// make another fake request
// let's pretend that this takes an ID and makes a fake ajax request to get teh data
// getValueData :: String -> Future
const getValueData = id => Future((reject, resolve) =>
// fake HTTP request
setTimeout(() =>
resolve(
id: id,
foo: 'bar'
)
, 100)
)

// 'one' should then run getValueData
getVal('one')
.chain(maybeToFuture)
.chain(getValueData)
.fork(console.error, console.log)

// five isn't there so getValueData doesn't run
getVal('five')
.chain(maybeToFuture)
.chain(getValueData)
.fork(console.error, console.log)





share|improve this answer

























  • This doesn't look right, you're not using Maybe at all any more. Also your type annotation is wrong now, it should be getVal :: String -> Future (Future String)

    – Bergi
    Nov 13 '18 at 19:37











  • added Maybe implementation

    – Matt Sanders
    Nov 14 '18 at 1:05











  • It still converts the Maybe to a Future (and rejects it!) instead of creating a Future (Maybe String) which is what I understood you originally were looking for?

    – Bergi
    Nov 14 '18 at 17:32










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53269025%2fhandling-nested-maybe-monad-inside-future%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














You must be looking for the sequence operations that could turn the Maybe<Future<…>> into a Future<Maybe<…>> which you can then join into your outer future.



With traverse:



getVal('one')
.chain(traverse(Future.of, getValueData))
.fork(console.error, console.log)





share|improve this answer























  • Hey Bergi, thanks for the response, that example didn't quite work. care to elaborate further?

    – Matt Sanders
    Nov 12 '18 at 22:50











  • It definitely should work, however traverse always seems to assume a list type not a Maybe. I don't know why, you might want to file a Ramda bug.

    – Bergi
    Nov 13 '18 at 19:52















0














You must be looking for the sequence operations that could turn the Maybe<Future<…>> into a Future<Maybe<…>> which you can then join into your outer future.



With traverse:



getVal('one')
.chain(traverse(Future.of, getValueData))
.fork(console.error, console.log)





share|improve this answer























  • Hey Bergi, thanks for the response, that example didn't quite work. care to elaborate further?

    – Matt Sanders
    Nov 12 '18 at 22:50











  • It definitely should work, however traverse always seems to assume a list type not a Maybe. I don't know why, you might want to file a Ramda bug.

    – Bergi
    Nov 13 '18 at 19:52













0












0








0







You must be looking for the sequence operations that could turn the Maybe<Future<…>> into a Future<Maybe<…>> which you can then join into your outer future.



With traverse:



getVal('one')
.chain(traverse(Future.of, getValueData))
.fork(console.error, console.log)





share|improve this answer













You must be looking for the sequence operations that could turn the Maybe<Future<…>> into a Future<Maybe<…>> which you can then join into your outer future.



With traverse:



getVal('one')
.chain(traverse(Future.of, getValueData))
.fork(console.error, console.log)






share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 12 '18 at 22:27









BergiBergi

369k58551878




369k58551878












  • Hey Bergi, thanks for the response, that example didn't quite work. care to elaborate further?

    – Matt Sanders
    Nov 12 '18 at 22:50











  • It definitely should work, however traverse always seems to assume a list type not a Maybe. I don't know why, you might want to file a Ramda bug.

    – Bergi
    Nov 13 '18 at 19:52

















  • Hey Bergi, thanks for the response, that example didn't quite work. care to elaborate further?

    – Matt Sanders
    Nov 12 '18 at 22:50











  • It definitely should work, however traverse always seems to assume a list type not a Maybe. I don't know why, you might want to file a Ramda bug.

    – Bergi
    Nov 13 '18 at 19:52
















Hey Bergi, thanks for the response, that example didn't quite work. care to elaborate further?

– Matt Sanders
Nov 12 '18 at 22:50





Hey Bergi, thanks for the response, that example didn't quite work. care to elaborate further?

– Matt Sanders
Nov 12 '18 at 22:50













It definitely should work, however traverse always seems to assume a list type not a Maybe. I don't know why, you might want to file a Ramda bug.

– Bergi
Nov 13 '18 at 19:52





It definitely should work, however traverse always seems to assume a list type not a Maybe. I don't know why, you might want to file a Ramda bug.

– Bergi
Nov 13 '18 at 19:52













0














Managed to solve my own problem, partially because of Bergi's suggestion. Bergi's answer above was very close, but the implementation wasn't quite right. The issue was that I was trying to deal with a Future and then change it to a Maybe, so I dealt with it with the following:



import R from "ramda";
import Fantasy from "ramda-fantasy";
const Future = Fantasy.Future;
const Maybe = Fantasy.Maybe;

// make a fake HTTP request and return a list of values
// response :: Future Array String
const response = Future.of(['one', 'two', 'three'])

const maybeOrNothing = val => val ? Maybe.Just(val) : Maybe.Nothing()
const maybeToFuture = m => Maybe.isNothing(m) ? Future.reject() : Future.of(m.value)

// Maybe return our given value
// getVal :: String -> Maybe String
const getVal = input => response.map(R.find(R.equals(input))).map(maybeOrNothing)

// make another fake request
// let's pretend that this takes an ID and makes a fake ajax request to get teh data
// getValueData :: String -> Future
const getValueData = id => Future((reject, resolve) =>
// fake HTTP request
setTimeout(() =>
resolve(
id: id,
foo: 'bar'
)
, 100)
)

// 'one' should then run getValueData
getVal('one')
.chain(maybeToFuture)
.chain(getValueData)
.fork(console.error, console.log)

// five isn't there so getValueData doesn't run
getVal('five')
.chain(maybeToFuture)
.chain(getValueData)
.fork(console.error, console.log)





share|improve this answer

























  • This doesn't look right, you're not using Maybe at all any more. Also your type annotation is wrong now, it should be getVal :: String -> Future (Future String)

    – Bergi
    Nov 13 '18 at 19:37











  • added Maybe implementation

    – Matt Sanders
    Nov 14 '18 at 1:05











  • It still converts the Maybe to a Future (and rejects it!) instead of creating a Future (Maybe String) which is what I understood you originally were looking for?

    – Bergi
    Nov 14 '18 at 17:32















0














Managed to solve my own problem, partially because of Bergi's suggestion. Bergi's answer above was very close, but the implementation wasn't quite right. The issue was that I was trying to deal with a Future and then change it to a Maybe, so I dealt with it with the following:



import R from "ramda";
import Fantasy from "ramda-fantasy";
const Future = Fantasy.Future;
const Maybe = Fantasy.Maybe;

// make a fake HTTP request and return a list of values
// response :: Future Array String
const response = Future.of(['one', 'two', 'three'])

const maybeOrNothing = val => val ? Maybe.Just(val) : Maybe.Nothing()
const maybeToFuture = m => Maybe.isNothing(m) ? Future.reject() : Future.of(m.value)

// Maybe return our given value
// getVal :: String -> Maybe String
const getVal = input => response.map(R.find(R.equals(input))).map(maybeOrNothing)

// make another fake request
// let's pretend that this takes an ID and makes a fake ajax request to get teh data
// getValueData :: String -> Future
const getValueData = id => Future((reject, resolve) =>
// fake HTTP request
setTimeout(() =>
resolve(
id: id,
foo: 'bar'
)
, 100)
)

// 'one' should then run getValueData
getVal('one')
.chain(maybeToFuture)
.chain(getValueData)
.fork(console.error, console.log)

// five isn't there so getValueData doesn't run
getVal('five')
.chain(maybeToFuture)
.chain(getValueData)
.fork(console.error, console.log)





share|improve this answer

























  • This doesn't look right, you're not using Maybe at all any more. Also your type annotation is wrong now, it should be getVal :: String -> Future (Future String)

    – Bergi
    Nov 13 '18 at 19:37











  • added Maybe implementation

    – Matt Sanders
    Nov 14 '18 at 1:05











  • It still converts the Maybe to a Future (and rejects it!) instead of creating a Future (Maybe String) which is what I understood you originally were looking for?

    – Bergi
    Nov 14 '18 at 17:32













0












0








0







Managed to solve my own problem, partially because of Bergi's suggestion. Bergi's answer above was very close, but the implementation wasn't quite right. The issue was that I was trying to deal with a Future and then change it to a Maybe, so I dealt with it with the following:



import R from "ramda";
import Fantasy from "ramda-fantasy";
const Future = Fantasy.Future;
const Maybe = Fantasy.Maybe;

// make a fake HTTP request and return a list of values
// response :: Future Array String
const response = Future.of(['one', 'two', 'three'])

const maybeOrNothing = val => val ? Maybe.Just(val) : Maybe.Nothing()
const maybeToFuture = m => Maybe.isNothing(m) ? Future.reject() : Future.of(m.value)

// Maybe return our given value
// getVal :: String -> Maybe String
const getVal = input => response.map(R.find(R.equals(input))).map(maybeOrNothing)

// make another fake request
// let's pretend that this takes an ID and makes a fake ajax request to get teh data
// getValueData :: String -> Future
const getValueData = id => Future((reject, resolve) =>
// fake HTTP request
setTimeout(() =>
resolve(
id: id,
foo: 'bar'
)
, 100)
)

// 'one' should then run getValueData
getVal('one')
.chain(maybeToFuture)
.chain(getValueData)
.fork(console.error, console.log)

// five isn't there so getValueData doesn't run
getVal('five')
.chain(maybeToFuture)
.chain(getValueData)
.fork(console.error, console.log)





share|improve this answer















Managed to solve my own problem, partially because of Bergi's suggestion. Bergi's answer above was very close, but the implementation wasn't quite right. The issue was that I was trying to deal with a Future and then change it to a Maybe, so I dealt with it with the following:



import R from "ramda";
import Fantasy from "ramda-fantasy";
const Future = Fantasy.Future;
const Maybe = Fantasy.Maybe;

// make a fake HTTP request and return a list of values
// response :: Future Array String
const response = Future.of(['one', 'two', 'three'])

const maybeOrNothing = val => val ? Maybe.Just(val) : Maybe.Nothing()
const maybeToFuture = m => Maybe.isNothing(m) ? Future.reject() : Future.of(m.value)

// Maybe return our given value
// getVal :: String -> Maybe String
const getVal = input => response.map(R.find(R.equals(input))).map(maybeOrNothing)

// make another fake request
// let's pretend that this takes an ID and makes a fake ajax request to get teh data
// getValueData :: String -> Future
const getValueData = id => Future((reject, resolve) =>
// fake HTTP request
setTimeout(() =>
resolve(
id: id,
foo: 'bar'
)
, 100)
)

// 'one' should then run getValueData
getVal('one')
.chain(maybeToFuture)
.chain(getValueData)
.fork(console.error, console.log)

// five isn't there so getValueData doesn't run
getVal('five')
.chain(maybeToFuture)
.chain(getValueData)
.fork(console.error, console.log)






share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 14 '18 at 1:05

























answered Nov 13 '18 at 19:18









Matt SandersMatt Sanders

1169




1169












  • This doesn't look right, you're not using Maybe at all any more. Also your type annotation is wrong now, it should be getVal :: String -> Future (Future String)

    – Bergi
    Nov 13 '18 at 19:37











  • added Maybe implementation

    – Matt Sanders
    Nov 14 '18 at 1:05











  • It still converts the Maybe to a Future (and rejects it!) instead of creating a Future (Maybe String) which is what I understood you originally were looking for?

    – Bergi
    Nov 14 '18 at 17:32

















  • This doesn't look right, you're not using Maybe at all any more. Also your type annotation is wrong now, it should be getVal :: String -> Future (Future String)

    – Bergi
    Nov 13 '18 at 19:37











  • added Maybe implementation

    – Matt Sanders
    Nov 14 '18 at 1:05











  • It still converts the Maybe to a Future (and rejects it!) instead of creating a Future (Maybe String) which is what I understood you originally were looking for?

    – Bergi
    Nov 14 '18 at 17:32
















This doesn't look right, you're not using Maybe at all any more. Also your type annotation is wrong now, it should be getVal :: String -> Future (Future String)

– Bergi
Nov 13 '18 at 19:37





This doesn't look right, you're not using Maybe at all any more. Also your type annotation is wrong now, it should be getVal :: String -> Future (Future String)

– Bergi
Nov 13 '18 at 19:37













added Maybe implementation

– Matt Sanders
Nov 14 '18 at 1:05





added Maybe implementation

– Matt Sanders
Nov 14 '18 at 1:05













It still converts the Maybe to a Future (and rejects it!) instead of creating a Future (Maybe String) which is what I understood you originally were looking for?

– Bergi
Nov 14 '18 at 17:32





It still converts the Maybe to a Future (and rejects it!) instead of creating a Future (Maybe String) which is what I understood you originally were looking for?

– Bergi
Nov 14 '18 at 17:32

















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53269025%2fhandling-nested-maybe-monad-inside-future%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

What does pagestruct do in Eviews?

Dutch intervention in Lombok and Karangasem

Channel Islands