diff --git a/src/Import/NoFoundation.hs b/src/Import/NoFoundation.hs index 266ad727b..73e1dbe8d 100644 --- a/src/Import/NoFoundation.hs +++ b/src/Import/NoFoundation.hs @@ -18,6 +18,7 @@ import Yesod.Default.Config2 as Import import Utils as Import import Utils.Frontend.Modal as Import import Utils.Frontend.I18n as Import +import Utils.DB as Import import Yesod.Core.Json as Import (provideJson) import Yesod.Core.Types.Instances as Import (CachedMemoT(..)) diff --git a/src/Utils.hs b/src/Utils.hs index 7a4758f4a..4ca14e49c 100644 --- a/src/Utils.hs +++ b/src/Utils.hs @@ -19,7 +19,7 @@ import qualified Data.ByteString.Lazy as LBS import qualified Data.Text as Text import qualified Data.Text.Encoding as Text -import Utils.DB as Utils +-- import Utils.DB as Utils import Utils.TH as Utils import Utils.DateTime as Utils import Utils.PathPiece as Utils @@ -420,11 +420,13 @@ toNothing = const Nothing toNothingS :: String -> Maybe b toNothingS = const Nothing --- MOVED TO UTILS.DB due to cyclic dependency --- Swap 'Nothing' for 'Just' and vice versa --- flipMaybe :: b -> Maybe b -> Maybe b --- flipMaybe x Nothing = Just x --- flipMaybe _ (Just _) = Nothing +-- | Swap 'Nothing' for 'Just' and vice versa +-- This belongs into Module 'Utils' but we have a weird cyclic +-- dependency +flipMaybe :: b -> Maybe a -> Maybe b +flipMaybe x Nothing = Just x +flipMaybe _ (Just _) = Nothing + maybeAdd :: Num a => Maybe a -> Maybe a -> Maybe a -- treats Nothing as neutral/zero, unlike fmap/ap maybeAdd (Just x) (Just y) = Just (x + y) diff --git a/src/Utils/DB.hs b/src/Utils/DB.hs index b6e7b9950..de6a3c0fa 100644 --- a/src/Utils/DB.hs +++ b/src/Utils/DB.hs @@ -10,13 +10,8 @@ import qualified Data.Set as Set import qualified Database.Esqueleto as E -- import Database.Persist -- currently not needed here +import Utils --- | Swap 'Nothing' for 'Just' and vice versa --- This belongs into Module 'Utils' but we have a weird cyclic --- dependency -flipMaybe :: b -> Maybe a -> Maybe b -flipMaybe x Nothing = Just x -flipMaybe _ (Just _) = Nothing