Skip to content

Commit ed16e73

Browse files
authored
Merge pull request #15 from alexfmpe/develop
Build with ghc 9.10
2 parents 29e0c5b + 64cd8a6 commit ed16e73

File tree

4 files changed

+33
-27
lines changed

4 files changed

+33
-27
lines changed

.github/workflows/haskell.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ jobs:
66
build:
77
strategy:
88
matrix:
9-
ghc: ['8.6.5', '8.10.7']
9+
ghc: ['8.6', '8.8', '8.10', '9.0', '9.2', '9.4', '9.6', '9.8', '9.10']
1010
os: ['ubuntu-latest', 'macos-latest']
1111
runs-on: ${{ matrix.os }}
1212

@@ -16,7 +16,6 @@ jobs:
1616
- uses: haskell/actions/setup@v2
1717
with:
1818
ghc-version: ${{ matrix.ghc }}
19-
cabal-version: '3.10.1.0'
2019
- name: Cache
2120
uses: actions/cache@v3
2221
env:
@@ -31,10 +30,15 @@ jobs:
3130
${{ runner.os }}
3231
3332
- name: Install dependencies
34-
run: cabal build --only-dependencies --enable-tests --enable-benchmarks
33+
run: |
34+
cabal update
35+
cabal build --only-dependencies --enable-tests --enable-benchmarks
36+
3537
- name: Build
3638
run: cabal build --enable-tests --enable-benchmarks all
39+
3740
- name: Run tests
3841
run: cabal test all
42+
3943
- name: Build Docs
4044
run: cabal haddock

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
dist-newstyle

Readme.md

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,23 @@ Let's start with some imports and language pragmas.
3030
> {-# LANGUAGE TemplateHaskell #-}
3131
> {-# LANGUAGE TypeFamilies #-}
3232
> {-# LANGUAGE UndecidableInstances #-}
33-
>
33+
3434
> module Readme where
35-
>
35+
3636
> import Control.Monad (void)
3737
> import Control.Monad.IO.Class (MonadIO)
3838
> import Control.Monad.Fix (MonadFix)
3939
> import Data.Aeson (ToJSON(..), FromJSON(..))
4040
> import Data.Aeson.GADT.TH (deriveJSONGADT)
4141
> import Data.Constraint.Extras (Has)
4242
> import Data.Constraint.Extras.TH (deriveArgDict)
43+
> import Data.Kind (Type)
4344
> import Data.Text as T (Text, null, pack)
4445
> import Data.Time (UTCTime, Day)
4546
> import GHC.Generics (Generic)
4647
> import Reflex.Dom.Core
4748
> import Reflex.Dom.GadtApi
48-
>
49+
4950

5051
```
5152

@@ -60,30 +61,30 @@ The code that follows would typically go in a common module, since it would be u
6061
> , _dog_imageUri :: Maybe Text
6162
> }
6263
> deriving (Generic)
63-
>
64+
6465
> instance ToJSON Dog
6566
> instance FromJSON Dog
66-
>
67+
6768

6869
```
6970

7071
Here we have an API for retrieving and interacting with the `Dog` data:
7172

7273
```haskell
7374

74-
> data DogApi :: * -> * where
75+
> data DogApi :: Type -> Type where
7576
> DogApi_GetByDay :: Day -> DogApi [Dog]
7677
> DogApi_GetByName :: Text -> DogApi [Dog]
7778
> DogApi_GetLastSeen :: DogApi (Maybe Dog)
7879
> DogApi_ReportSighting :: Text -> Bool -> Maybe Text -> DogApi (Either Text ())
7980
> DogApi_GetSuspiciousSightings :: DogApi [Dog]
80-
>
81+
8182
> newtype Token = Token { unToken :: Text }
8283
> deriving (Generic)
83-
>
84+
8485
> instance ToJSON Token
8586
> instance FromJSON Token
86-
>
87+
8788

8889
```
8990

@@ -94,12 +95,12 @@ We can take the `DogApi` and embed it in another GADT API. This outer API will h
9495
> data CatApi a where
9596
> CatApi_Identify :: Text -> CatApi (Either Text Token)
9697
> CatApi_DogApi :: Token -> DogApi a -> CatApi a
97-
>
98+
9899
> deriveJSONGADT ''DogApi
99100
> deriveJSONGADT ''CatApi
100101
> deriveArgDict ''DogApi
101102
> deriveArgDict ''CatApi
102-
>
103+
103104

104105
```
105106

@@ -108,7 +109,7 @@ On the frontend, we'll run a `RequesterT` widget that allows us to emit an event
108109
```haskell
109110

110111
> type Catnet t m = (RequesterT t CatApi (Either Text) m)
111-
>
112+
112113

113114
```
114115

@@ -178,7 +179,7 @@ We're using reflex `Workflow`s to switch between pages, but we could accomplish
178179
> rsp <- dogSighting token
179180
> leave <- delay 3 rsp
180181
> pure ((), catnetW token <$ leave) -- Go back to catnet
181-
>
182+
182183

183184
```
184185

@@ -191,7 +192,7 @@ If you're building your frontend in a context where the user interface needs to
191192
> => Event t (Request (Client (Catnet t m)) a)
192193
> -> Catnet t m (Event t (Response (Client (Catnet t m)) a))
193194
> requestingJs r = fmap (switch . current) $ prerender (pure never) $ requesting r
194-
>
195+
195196

196197
```
197198

@@ -214,7 +215,7 @@ The response from the server is an `Event` that can be used to update the user i
214215
> Right (Right catToken) -> Just catToken
215216
> _ -> Nothing
216217
> pure token
217-
>
218+
218219

219220
```
220221

@@ -246,7 +247,7 @@ This function builds a UI with a few buttons. Depending on which button is click
246247
> Right dogs -> el "ul" $ mapM_ (el "li" . showDog) dogs
247248
> -- Return the "Report a sighting" click event
248249
> pure addDog
249-
>
250+
250251

251252
```
252253

@@ -268,7 +269,7 @@ The `showDog` widget below does not have `Catnet` or `RequesterT` in its type si
268269
> el "dd" $ case _dog_imageUri dog of
269270
> Just img -> elAttr "img" ("src" =: img <> "alt" =: "dog mugshot") blank
270271
> Nothing -> text "None"
271-
>
272+
272273

273274
```
274275

@@ -318,7 +319,7 @@ Once we've got those three values, we can apply them to the `DogApi_ReportSighti
318319
> Right (Left err) -> Left err
319320
> Left err -> Left err
320321
> Right (Right result) -> Right result
321-
>
322+
322323
> main :: IO ()
323324
> main = return ()
324325

reflex-gadt-api.cabal

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ description:
66
This package is designed to be used in full-stack Haskell applications where the API is defined as a GADT and the frontend is using reflex-dom.
77

88
bug-reports: https://github.com/reflex-frp/reflex-gadt-api/issues
9-
license: BSD3
9+
license: BSD3
1010
license-file: LICENSE
1111
author: Obsidian Systems
1212
maintainer: [email protected]
@@ -24,16 +24,16 @@ library
2424
build-depends:
2525
aeson >=1.4.4 && <2.3
2626
, aeson-gadt-th >=0.2.4 && <0.3
27-
, base >=4.12 && <4.16
28-
, bytestring >=0.10.8 && <0.11
27+
, base >=4.12 && <4.21
28+
, bytestring >=0.10.8 && <0.13
2929
, constraints-extras >=0.3.0 && <0.5
30-
, containers >=0.6 && <0.7
31-
, data-default >=0.6 && <0.8
30+
, containers >=0.6 && <0.8
31+
, data-default >=0.6 && <0.9
3232
, jsaddle >=0.9.7 && <0.10
3333
, reflex >=0.7 && <1
3434
, reflex-dom-core >=0.7.0 && <0.9
3535
, some >=1 && <1.1
36-
, text >=1.2 && <1.3
36+
, text >=1.2 && <2.2
3737
, time >=1.6.0 && <2
3838

3939
exposed-modules:

0 commit comments

Comments
 (0)