flipMaybe moved to Utils
This commit is contained in:
parent
2dacc39486
commit
36347aa832
@ -18,6 +18,7 @@ import Yesod.Default.Config2 as Import
|
|||||||
import Utils as Import
|
import Utils as Import
|
||||||
import Utils.Frontend.Modal as Import
|
import Utils.Frontend.Modal as Import
|
||||||
import Utils.Frontend.I18n as Import
|
import Utils.Frontend.I18n as Import
|
||||||
|
import Utils.DB as Import
|
||||||
import Yesod.Core.Json as Import (provideJson)
|
import Yesod.Core.Json as Import (provideJson)
|
||||||
import Yesod.Core.Types.Instances as Import (CachedMemoT(..))
|
import Yesod.Core.Types.Instances as Import (CachedMemoT(..))
|
||||||
|
|
||||||
|
|||||||
14
src/Utils.hs
14
src/Utils.hs
@ -19,7 +19,7 @@ import qualified Data.ByteString.Lazy as LBS
|
|||||||
import qualified Data.Text as Text
|
import qualified Data.Text as Text
|
||||||
import qualified Data.Text.Encoding 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.TH as Utils
|
||||||
import Utils.DateTime as Utils
|
import Utils.DateTime as Utils
|
||||||
import Utils.PathPiece as Utils
|
import Utils.PathPiece as Utils
|
||||||
@ -420,11 +420,13 @@ toNothing = const Nothing
|
|||||||
toNothingS :: String -> Maybe b
|
toNothingS :: String -> Maybe b
|
||||||
toNothingS = const Nothing
|
toNothingS = const Nothing
|
||||||
|
|
||||||
-- MOVED TO UTILS.DB due to cyclic dependency
|
-- | Swap 'Nothing' for 'Just' and vice versa
|
||||||
-- Swap 'Nothing' for 'Just' and vice versa
|
-- This belongs into Module 'Utils' but we have a weird cyclic
|
||||||
-- flipMaybe :: b -> Maybe b -> Maybe b
|
-- dependency
|
||||||
-- flipMaybe x Nothing = Just x
|
flipMaybe :: b -> Maybe a -> Maybe b
|
||||||
-- flipMaybe _ (Just _) = Nothing
|
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 :: Num a => Maybe a -> Maybe a -> Maybe a -- treats Nothing as neutral/zero, unlike fmap/ap
|
||||||
maybeAdd (Just x) (Just y) = Just (x + y)
|
maybeAdd (Just x) (Just y) = Just (x + y)
|
||||||
|
|||||||
@ -10,13 +10,8 @@ import qualified Data.Set as Set
|
|||||||
import qualified Database.Esqueleto as E
|
import qualified Database.Esqueleto as E
|
||||||
-- import Database.Persist -- currently not needed here
|
-- 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
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user