Skip to content

Commit

Permalink
Merge pull request #952 from obsidiansystems/ae@encoder-semigroupoid
Browse files Browse the repository at this point in the history
Add Semigroupoid instance to Encoder
  • Loading branch information
madeline-os authored Jul 26, 2022
2 parents 35f731b + f865dca commit ec10670
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
1 change: 1 addition & 0 deletions lib/route/obelisk-route.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ library
ref-tf,
reflex,
reflex-dom-core,
semigroupoids,
template-haskell,
tabulation,
text,
Expand Down
6 changes: 5 additions & 1 deletion lib/route/src/Obelisk/Route.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit ec10670

Please sign in to comment.