[prev in list] [next in list] [prev in thread] [next in thread] 

List:       haskell-cafe
Subject:    Re: [Haskell-cafe] Haskell and symbolic references
From:       Khudyakov Alexey <alexey.skladnoy () gmail ! com>
Date:       2009-05-29 16:41:46
Message-ID: 200905292041.46886.alexey.skladnoy () gmail ! com
[Download RAW message or body]

On Friday 29 of May 2009 19:34:44 Patrick LeBoutillier wrote:
> Hi all,
>
> Is it possible with Haskell to call a function whose name is contained
> in a String?
> Something like:
>
> five = call_func "add" [2, 3]
>
> If not, perhaps this is acheivable using FFI?
>
Or maybe you are asking for template haskell[1]. With it you can actually 
generate function at compile time. It depends on waht you actually need.

> {-# LANGUAGE TemplateHaskell #-}
> import Language.Haskell.TH
>
> five = $( foldl appE (varE $ mkName "+") [ litE $ integerL 2
>                                          , litE $ integerL 3 ] )


[1] http://haskell.org/haskellwiki/Template_Haskell

--
  Khudyakov Alexey
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic