Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions nix/shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ let
enable = true;
package = tools.fourmolu;
};
hlint = {
enable = true;
package = tools.hlint;
};
nixpkgs-fmt = {
enable = true;
package = pkgs.nixpkgs-fmt;
Expand Down
13 changes: 8 additions & 5 deletions src/Codec/CBOR/Cuddle/Huddle.hs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@
import Codec.CBOR.Cuddle.CDDL qualified as C
import Codec.CBOR.Cuddle.CDDL.CtlOp qualified as CtlOp
import Codec.CBOR.Cuddle.Comments qualified as C
import Control.Monad (when)
import Control.Monad.State (MonadState (get), execState, modify)
import Data.ByteString (ByteString)
import Data.Default.Class (Default (..))
Expand Down Expand Up @@ -1017,6 +1016,12 @@
(traverse goHuddleItem topRs)
OMap.empty
where
whenNotDefined n m = do
items <- get
if OMap.notMember n items
then m
else error $ "Duplicate definitions found: " <> show n

toHuddle items =
Huddle
{ roots = concatMap hiRule topRs
Expand All @@ -1026,21 +1031,19 @@
goHuddleItem (HIGroup g) = goNamedGroup g
goHuddleItem (HIGRule (Named _ (GRule _ t0) _)) = goT0 t0
goRule r@(Named n t0 _) = do
items <- get
when (OMap.notMember n items) $ do
whenNotDefined n $ do
modify (OMap.|> (n, HIRule r))
goT0 t0
goChoice f (NoChoice x) = f x
goChoice f (ChoiceOf x xs) = f x >> goChoice f xs
goT0 = goChoice goT2
goNamedGroup r@(Named n g _) = do
items <- get
when (OMap.notMember n items) $ do
whenNotDefined n $ do
modify (OMap.|> (n, HIGroup r))
goGroup g
goGRule r@(Named n g _) = do
items <- get
when (OMap.notMember n items) $ do

Check failure on line 1046 in src/Codec/CBOR/Cuddle/Huddle.hs

View workflow job for this annotation

GitHub Actions / Stack (ubuntu-latest, lts-23)

Variable not in scope: when :: Bool -> m () -> m a0

Check failure on line 1046 in src/Codec/CBOR/Cuddle/Huddle.hs

View workflow job for this annotation

GitHub Actions / Stack (ubuntu-latest, nightly)

Variable not in scope: when :: Bool -> m () -> m a0

Check failure on line 1046 in src/Codec/CBOR/Cuddle/Huddle.hs

View workflow job for this annotation

GitHub Actions / Stack (ubuntu-latest, lts-22)

Variable not in scope: when :: Bool -> m () -> m a0

Check failure on line 1046 in src/Codec/CBOR/Cuddle/Huddle.hs

View workflow job for this annotation

GitHub Actions / Stack (ubuntu-latest, lts-24)

Variable not in scope: when :: Bool -> m () -> m a0
modify (OMap.|> (n, HIGRule $ fmap callToDef r))
goT0 (body g)
-- Note that the parameters here may be different, so this doesn't live
Expand Down
Loading