{"id":20801996,"url":"https://github.com/philips-software/iaf-observation","last_synced_at":"2025-10-08T11:29:53.214Z","repository":{"id":96542227,"uuid":"143155831","full_name":"philips-software/iaf-observation","owner":"philips-software","description":"Type-safe composition and transformation of data points","archived":false,"fork":false,"pushed_at":"2022-04-20T06:13:27.000Z","size":32,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-01-18T12:34:36.018Z","etag":null,"topics":["iaf"],"latest_commit_sha":null,"homepage":null,"language":"Scala","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/philips-software.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-08-01T12:54:50.000Z","updated_at":"2022-04-20T06:13:30.000Z","dependencies_parsed_at":"2023-04-04T06:17:15.506Z","dependency_job_id":null,"html_url":"https://github.com/philips-software/iaf-observation","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/philips-software%2Fiaf-observation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/philips-software%2Fiaf-observation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/philips-software%2Fiaf-observation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/philips-software%2Fiaf-observation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/philips-software","download_url":"https://codeload.github.com/philips-software/iaf-observation/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243147270,"owners_count":20243745,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["iaf"],"created_at":"2024-11-17T18:27:13.867Z","updated_at":"2025-10-08T11:29:48.144Z","avatar_url":"https://github.com/philips-software.png","language":"Scala","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.com/philips-software/iaf-observation.svg?branch=master)](https://travis-ci.com/philips-software/iaf-observation)\n\n⚠️ This project is no longer supported.\n\nThe Observation Monad\n======\n\nThe observation monad allows for the functional composition and manipulation of data points of various data types in a type-safe manner. The monad is written in Scala and is compatible with the [Cats](https://typelevel.org/cats) framework, which provides a plethora of other useful functional programming concepts. The observation monad can be used as a component in other software projects for low-level data-processing in a functional manner.\n\nBefore using the observation monad, we recommend some familiarity with monadic programming. To learn more about functional programming concepts in the context of the Cats framework, please refer to the [Cats documentation](https://typelevel.org/cats/typeclasses/monad.html).\n\n## Dependencies\n\nThis software requires the [scala build tool (SBT) version 1.1.1 or higher](http://www.scala-sbt.org/) to be installed on your system. Installation instructions for various platforms can be found [here](https://www.scala-sbt.org/1.0/docs/Setup.html).\n\n## Installation\n\nWe are currently taking steps to make this project available on Maven Central.\n\n## Usage\n\nTo run the examples, execute `sbt run` in the root project directory. This will return a list of all examples. Select an example to be executed by entering the corresponding number. To run a specific example, execute `sbt runMain` followed by the class to run (e.g. `sbt runMain com.philips.research.iaf.observation.examples.CreatingObservations`). Examples can be viewed [here](src/main/scala/com/philips/research/iaf/observation/examples).\n\n### Example 1: combining observations\n\nThe example below shows the creation of two observations length and weight, containing a value of type `double` and `int`, respectively. The observations are subsequently combined in a for-comprehension to create a new observation, containing a `double` value, indicating the BMI computed from the length and weight values.\n\n```scala\nimport Observation._\n\n//Create a length (double) observation and weight (int) observation\nval lengthObservation = pure(1.82d)\nval weightObservation = pure(100)\n\n//Derive a new observation 'bmi' (double) from combining the values contained in the previous two observations\nval bmi = for{\n  length \u003c- lengthObservation\n  weight \u003c- weightObservation\n} yield weight / Math.pow(length, 2)\n\n//Print the result\nprintln(s\"BMI: $bmi\")\n//Outputs \"BMI: Observation(30.189590629151066)\"\n```\n\n### Example 2: transforming future observations\n\nThe example below shows how the `string` value of a future observation (i.e. `Future[Observation[String]]`) is changed by mapping over the future observation. This is done by using the [observation transformer](src/main/scala/com/philips/research/iaf/observation/ObservationT.scala).\n\n```scala\n//Create a future observation with a string value, wrapping it in the observation transformer\nval futureStringObservation = ObservationT(Future.successful(Observation.pure(\"hi!\")))\n\n//Map the string value of this future observation to an int value, while preserving the context of the future observation\nval futureIntObservation = futureStringObservation.map(_.length)\n\n//Print the result of the future on completion\nfutureIntObservation.value.onComplete{case Success(o) =\u003e println(s\"The future observation completed with result: $o\")}\n```\n\n### Example 3: using the observation monad with Cats\n\nThe examples below show how observations can be used within the Cats framework.\n\n```scala\n//Create an Observation[Int] using Cats' Monad type class\nval o1 = Monad[Observation].pure(5)\nprintln(s\"Created observation $o1\")\n//Outputs \"Created observation Observation(5)\"\n\n//Map the observation\nval o2 = Monad[Observation].map(o1)(x =\u003e x * 2)\nprintln(s\"Mapped to observation $o2\")\n//Outputs \"Mapped to observation Observation(10)\"\n\n//Use the observation monad in Cats' Option transformer\nval observationOption = OptionT.pure[Observation](2)\nprintln(s\"Created an OptionT[Observation]: $observationOption with value ${observationOption.value}\")\n//Outputs \"Created an OptionT[Observation]: OptionT(Observation(Some(2))) with value Observation(Some(2))\"\n\nval transformedObservationOption = observationOption.map(integer =\u003e integer + 5)\nprintln(s\"Transformed the value of the Observation[Option[Int]] to ${transformedObservationOption.value}\")\n//Outputs \"Transformed the value of the Observation[Option[Int]] to Observation(Some(7))\"\n```\n\n## How to test the software\n\nTo run the test suite, execute `sbt test` in the root project directory. This will resolve all dependencies and perform all tests, subsequently providing a report of the test results.\n\n## Known issues\n\n- None\n\n## Contact / Getting help\n\nContact one of the official maintainers listed [here](MAINTAINERS.md). Issues and bugs can be reported as explained in our [contributing guidelines](CONTRIBUTING.md).\n\n## License\n\nProvided [here](LICENSE.md).\n\n## Credits and references\n\nCredits to [Cats](https://typelevel.org/cats/) for providing the fundamental concepts on which this project is built.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphilips-software%2Fiaf-observation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphilips-software%2Fiaf-observation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphilips-software%2Fiaf-observation/lists"}