diff --git a/ChangeLog.md b/ChangeLog.md index 55a7bce88..a9ae33783 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -22,6 +22,7 @@ This project's release branch is `master`. This log is written from the perspect * obelisk-route * [#915](https://github.com/obsidiansystems/obelisk/pull/915): Add routeLinkAttr to Obelisk.Route.Frontend. This allows the creation of route links with additional, user-specified attributes. * [#918](https://github.com/obsidiansystems/obelisk/pull/918): Add GHC 8.10.7 support for `obelisk-route` + * [#952](https://github.com/obsidiansystems/obelisk/pull/952): Add a `Semigroupoid` instance for the `Encoder` type, compatible with its existing `Category` instance. * Javascript FFI * [#844](https://github.com/obsidiansystems/obelisk/pull/844): Jsaddle FFI example extended in skeleton (example project which is installed by `ob init`). Note the remark on minifier renaming in /skeleton/static/lib.js * [#903](https://github.com/obsidiansystems/obelisk/pull/903): Added support for a file which allows users to specify global variables and namespaces in JS, that should not be used by the Google Closure Compiler during minification of the GHCJS produced JS. See the [FAQ](FAQ.md). diff --git a/lib/route/obelisk-route.cabal b/lib/route/obelisk-route.cabal index bff42f265..1ccce3d88 100644 --- a/lib/route/obelisk-route.cabal +++ b/lib/route/obelisk-route.cabal @@ -29,6 +29,7 @@ library ref-tf, reflex, reflex-dom-core, + semigroupoids, template-haskell, tabulation, text, diff --git a/lib/route/src/Obelisk/Route.hs b/lib/route/src/Obelisk/Route.hs index c87edf8fa..aa350b5be 100644 --- a/lib/route/src/Obelisk/Route.hs +++ b/lib/route/src/Obelisk/Route.hs @@ -187,6 +187,7 @@ import qualified Data.Map as Map import Data.Maybe import Data.Set (Set) import qualified Data.Set as Set +import Data.Semigroupoid import Data.Some (Some(Some)) import Data.Tabulation import Data.Text (Text) @@ -373,9 +374,12 @@ checkEncoder :: (Applicative check', Functor check) -> check (Encoder check' parse decoded encoded) checkEncoder = fmap unsafeMkEncoder . unEncoder +instance (Applicative check, Monad parse) => Semigroupoid (Encoder check parse) where + Encoder f `o` Encoder g = Encoder $ liftA2 (.) f g + instance (Applicative check, Monad parse) => Category (Encoder check parse) where id = Encoder $ pure id - Encoder f . Encoder g = Encoder $ liftA2 (.) f g + (.) = o instance Monad parse => Category (EncoderImpl parse) where id = EncoderImpl