[Haskell-cafe] Trying to write 'safeFromInteger'

Neil Mitchell ndmitchell at gmail.com
Thu Apr 9 05:12:16 EDT 2009

>>> That seems a really weird way to write it! Who decided all auxiliary
>>> functions should be called go? (I think I'm blaming dons) - why not:
>>> sffi :: (Integral a,Num a) => Integer -> Maybe a
>>> sffi n | toInteger n2 == n = Just n2
>>>        | otherwise = Nothing
>>>     where n2 = fromInteger n
>> I know I was too lazy to clean it up :-P
>> ( I also blame Dons for 'go' )
> I think the Common Lisp community tends to use 'foo-aux' instead of
> 'go' for these sort of axillary functions.  But, then in Haskell we
> can't use hyphen as an identify character and underscore is not
> popular.  For this reason I started using fooAux in Haskell, but after
> learning that a single quote is valid identifier character I started
> using foo'.
> Other than using go and foo', what do people use in Haskell?

I use f, if I need several auxiliary functions I start at f and work
my way up alphabetically. I tend to go back to f2 if I go past h. Be
grateful you don't have to maintain my code :-)



PS. Here is some code from the filepath library I wrote, illustrating
how fantastic my naming scheme looks. (I think if I was writing it
today I'd have used a list comprehension for validChars, eliminating

makeValid path = joinDrive drv $ validElements $ validChars pth
        (drv,pth) = splitDrive path

        validChars x = map f x
        f x | x `elem` badCharacters = '_'
            | otherwise = x

        validElements x = joinPath $ map g $ splitPath x
        g x = h (reverse b) ++ reverse a
            where (a,b) = span isPathSeparator $ reverse x
        h x = if map toUpper a `elem` badElements then a ++ "_" <.> b else x
            where (a,b) = splitExtensions x

More information about the Haskell-Cafe mailing list