Skip to content

Commit

Permalink
More deps for doctest
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Díaz committed Apr 27, 2024
1 parent 930f611 commit a841df9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/haskell-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,8 @@ jobs:
- name: doctests
run: |
$CABAL v2-install $ARG_COMPILER --ghc-options="-rtsopts" doctest --overwrite-policy=always
$CABAL v2-repl lib:red-black-record --build-depends=QuickCheck --build-depends=template-haskell --with-ghc=doctest --repl-options='-w -Wdefault'
# the extra build-depends are for libraries used in the doctest examples
$CABAL v2-repl lib:red-black-record --build-depends=QuickCheck --build-depends=template-haskell --build-depends=text --build-depends=bytestring --build-depends=aeson --build-depends=sop-core --with-ghc=doctest --repl-options='-w -Wdefault'
- name: cabal check
run: |
cd ${PKGDIR_red_black_record} || false
Expand Down
8 changes: 4 additions & 4 deletions lib/Data/RBR/Examples.hs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ Just 5
parseSpecial transform =
let fieldParsers = transform $
cpure'_Record (Proxy @FromJSON) $ \fieldName -> Comp (fieldName,Kleisli parseJSON)
applyName (Comp (fieldName,Kleisli f)) = Kleisli (\o -> explicitParseField f o (Data.Text.pack fieldName))
applyName (Comp (fieldName,Kleisli f)) = Kleisli (\o -> explicitParseField f o (fromString fieldName))
Kleisli objectParser = sequence_Record $ liftA_Record applyName fieldParsers
in withObject "someobj" $ \o -> fromRecord <$> objectParser o
:}
Expand Down Expand Up @@ -227,7 +227,7 @@ Right (Person {name = "foo", age = 50})
-> Parser r
parseWithAliases aliases =
let fieldParsers = cpure_Record (Proxy @(ValueConstraint FromJSON)) (Kleisli parseJSON)
mapKSS (K name) (Kleisli pf) = Kleisli (\o -> explicitParseField pf o (Data.Text.pack name))
mapKSS (K name) (Kleisli pf) = Kleisli (\o -> explicitParseField pf o (fromString name))
Kleisli objectParser = sequence_Record $ liftA2_Record mapKSS aliases fieldParsers
in withObject "someobj" $ \o -> fromRecord <$> objectParser o
:}
Expand Down Expand Up @@ -269,7 +269,7 @@ Right (Person {name = "John", age = 50})
let subparser =
sequence_Record $
cpure'_Record (Proxy @FromJSON) $ \fieldName ->
Kleisli (\o -> explicitParseField parseJSON o (Data.Text.pack fieldName))
Kleisli (\o -> explicitParseField parseJSON o (fromString fieldName))
intoOriginal subrecord = fromRecord (S.setFieldSubset @subset subrecord (toRecord r))
Kleisli parser = intoOriginal <$> subparser
in withObject "someobj" parser
Expand Down Expand Up @@ -320,7 +320,7 @@ Person {name = "Mark", age = 70, whatever = True}
-> Parser r
parseAll =
let fieldParsers = cpure'_Record (Proxy @FromJSON) $ \fieldName ->
Kleisli (\o -> explicitParseField parseJSON o (Data.Text.pack fieldName))
Kleisli (\o -> explicitParseField parseJSON o (fromString fieldName))
injected = liftA2_Record (\f star -> K $ Alt $ runCase f . I <$> star) injections'_Variant fieldParsers
Alt (Kleisli parser) = collapse'_Record injected
in withObject "someobj" (\o -> fromVariant <$> parser o)
Expand Down

0 comments on commit a841df9

Please sign in to comment.