From 8ae0a55aff2b10fe70c647e373be527eb581cea1 Mon Sep 17 00:00:00 2001 From: Kazu Yamamoto Date: Wed, 10 Apr 2013 14:45:57 +0900 Subject: [PATCH] Using fromMaybe. --- CabalApi.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CabalApi.hs b/CabalApi.hs index e715fa6..82592f4 100644 --- a/CabalApi.hs +++ b/CabalApi.hs @@ -12,7 +12,7 @@ module CabalApi ( import Control.Applicative import Control.Exception (throwIO) import Data.List (intercalate) -import Data.Maybe (maybeToList, listToMaybe) +import Data.Maybe (maybeToList, listToMaybe, fromMaybe) import Data.Set (fromList, toList) import Distribution.Package (Dependency(Dependency), PackageName(PackageName)) import Distribution.PackageDescription @@ -71,7 +71,7 @@ getGHCOptions ghcOptions binfo = ghcOptions ++ exts ++ [lang] ++ libs ++ libDirs -- Causes error, catched in the upper function. cabalBuildInfo :: GenericPackageDescription -> BuildInfo -cabalBuildInfo pd = maybe emptyBuildInfo id $ fromLibrary pd <|> fromExecutable pd +cabalBuildInfo pd = fromMaybe emptyBuildInfo $ fromLibrary pd <|> fromExecutable pd where fromLibrary c = libBuildInfo . condTreeData <$> condLibrary c fromExecutable c = buildInfo . condTreeData . snd <$> listToMaybe (condExecutables c)