Skip to content

Commit

Permalink
Update haddock / changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
Tristano8 committed Sep 21, 2023
1 parent d07abed commit 96c60ed
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
18 changes: 17 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,23 @@

## 1.3.0.0

- Caching functions previously returned `m (t a)`, but it was easy to accidentally use `join` when `m` and `t` were the same monad (eg. `IO (IO a)`), and not get any caching at all. These functions now use a `Cached` newtype for `t a` to make it harder to do this.
- **Breaking** Caching functions previously returned `m (t a)`, but it was easy to accidentally use `join` when `m` and `t` were the same monad (eg. `IO (IO a)`), and not get any caching at all. These functions now use a `Cached` newtype for `t a` to make it more difficult to misuse.

### Migrating from <=1.2.0.0 to 1.3.0.0

```haskell
-- Previous versions
f :: IO ()
f = do
cachedAction <- cachedIO action :: IO (IO a)
cachedResult <- cachedAction

-- New version
f :: IO ()
f = do
cachedAction <- cachedIO action :: IO (Cached IO a)
cachedResult <- runCached cachedAction
```

## 1.2.0.0

Expand Down
2 changes: 1 addition & 1 deletion src/Control/Concurrent/CachedIO.hs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import Data.Time.Clock (NominalDiffTime, addUTCTime, getCurrentTime, UTCTime)

-- | A cached IO action in some monad @m@. Use 'runCached' to extract the action when you want to query it.
--
-- This newtype is intended to make it harder to accidentally 'Control.Monad.join' (and defeat all caching) when the fetch action and the outer monad are the same.
-- Note that using 'Control.Monad.join' when the cached action and the outer monad are the same will ignore caching.
newtype Cached m a = Cached {runCached :: m a}

data State a = Uninitialized | Initializing | Updating a | Fresh UTCTime a
Expand Down

0 comments on commit 96c60ed

Please sign in to comment.