{-# LANGUAGE FlexibleInstances, MultiParamTypeClasses #-} {-| Module : Data.Matroid.Internal.Helpers Description : Copyright : (c) Immanuel Albrecht, 2020-202x License : BSD-3 Maintainer : mail@immanuel-albrecht.de Stability : experimental Portability : POSIX This module provides internal helpers for the matroid package which fall into the 'general' category. -} module Data.Matroid.Internal.Helpers where -- | little helper that either chooses the implementation of a typeclass member from the record, or uses the default implementation defaultsTo :: (a0 -> Maybe a1) {- ^ record getter function -} -> a0 {- ^ the matroid -} -> (a1) {- ^ default implementation of the typeclass member -} -> a1 defaultsTo :: (a0 -> Maybe a1) -> a0 -> a1 -> a1 defaultsTo a0 -> Maybe a1 w_op a0 m a1 defImp = a1 -> (a1 -> a1) -> Maybe a1 -> a1 forall b a. b -> (a -> b) -> Maybe a -> b maybe a1 defImp a1 -> a1 forall a. a -> a id (Maybe a1 -> a1) -> Maybe a1 -> a1 forall a b. (a -> b) -> a -> b $ a0 -> Maybe a1 w_op a0 m