[Haskell-cafe] Abstracting a Genetic Algorithm

Rogan Creswick creswick at gmail.com
Wed Feb 16 02:21:56 CET 2011


On Tue, Feb 15, 2011 at 3:35 PM, Alex Good <alexjsgood at gmail.com> wrote:
>
> One bonus question, just a thing that's been bothering me, is there
> any way to create something like a type synonym for a function so that
> if I'm writing a function which takes functions as arguments I can
> write the synonym rather than the whole type signature of the function
> i.e so that something like the following would work.
>
> type someFunc = [Int] -> [Int] -> Int
> someOtherFunc :: someFunc -> [Int] -> Int

I think you just about have it right. Type names must still begin with
a leading capitol letter though.  See:
http://www.haskell.org/haskellwiki/Type#Type_and_newtype for examples,
but I this should work:

> type SomeFunc = [Int] -> [Int] -> Int
> someOtherFunc :: SomeFunc -> [Int] -> Int
> -- same as:
> -- someOtherFunc ::  ([Int] -> [Int] -> Int) -> [Int] -> Int

--Rogan

>
> Right, hopefully that's a lucid enough explanation of the problem,
> feel like I've missed the really obvious answer but it hasn't jumped
> out at me. Cheers
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>



More information about the Haskell-Cafe mailing list