From 5b1c59570396c83c38e151034964caa14b56362a Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Wed, 30 Mar 2016 19:16:33 +0200 Subject: [PATCH] LIB: move maybeD to MyPrelude --- src/Data/DirTree.hs | 4 +--- src/MyPrelude.hs | 6 ++++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Data/DirTree.hs b/src/Data/DirTree.hs index 422864f..af43c01 100644 --- a/src/Data/DirTree.hs +++ b/src/Data/DirTree.hs @@ -95,6 +95,7 @@ import HPath , pattern Path ) import qualified HPath as P +import MyPrelude import Safe ( atDef @@ -763,9 +764,6 @@ fromFreeVar :: (Default d) => (a -> d) -> File a -> d fromFreeVar f df = maybeD f $ getFreeVar df --- |A `maybe` flavor using the `Default` class. -maybeD :: (Default b) => (a -> b) -> Maybe a -> b -maybeD = maybe def -- |Pack the modification time into a string. diff --git a/src/MyPrelude.hs b/src/MyPrelude.hs index 6e0c147..95fb59a 100644 --- a/src/MyPrelude.hs +++ b/src/MyPrelude.hs @@ -19,9 +19,15 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. module MyPrelude where +import Data.Default import Data.List listIndices :: [a] -> [Int] listIndices = findIndices (const True) + + +-- |A `maybe` flavor using the `Default` class. +maybeD :: (Default b) => (a -> b) -> Maybe a -> b +maybeD = maybe def