cats/cats-effect and webservices function composition
cats/cats-effect and webservices function composition If you use webservices, say in a CLI program, then you are familiar with the following pattern: // typing in the types to show what they are... val entityA : IO [ Option [ A ] ] = getAByName ( "aname" ) val entityB : IO [ Option [ B ] ] = getBByName ( "bname" ) // ... // useIt does not return an Option. def useIt ( a : A , b : B , . . . ) : IO [ D ] = { . . . } // how do you call `useIt`? Here, the input “aname” comes from the user and is not a primary key (PK). The “get” has to search a list and if it finds a result, returns a single object. Or if the name is not found, it returns None . If the request finds more than 1 value, perhaps it returns None or signals an error (your choice). This is a classic problem in scala, that is, the effects returned in the get*ByName functions have efffect wrappers and we need to unwrap/drill-into them to use the data inside....