[Haskell-cafe] Convert a function to a string of operators?
Lyndon Maydwell
maydwell at gmail.com
Thu Mar 10 13:34:15 CET 2011
> Will methods explained here work for boolean expressions?
The convenience of defining using specialised datatypes for
serialising numeric operations comes from Num being a typeclass. This
is not the case for Bool:
Prelude> :info Num
class (Eq a, Show a) => Num a where
(+) :: a -> a -> a
... -- Defined in GHC.Num
Prelude> :info Bool
data Bool = False | True -- Defined in GHC.Bool
> Is there a way to extract parameter names from function definition to
> use them in Show instance? Or should I just use same names everywhere?
The only kind of introspection I know comes from Template Haskell, but
I'm sure there are other methods that I'm not aware of available.
On Sun, Mar 6, 2011 at 7:28 AM, Evgeny Grablyk <evgeny.grablyk at gmail.com> wrote:
> Many thanks for your help! Seems to be what I need. Two more related questions:
>
> Will methods explained here work for boolean expressions?
> Is there a way to extract parameter names from function definition to
> use them in Show instance? Or should I just use same names everywhere?
>
> In case that helps, here's the code I need to convert (the code in
> where part of solveScheme): http://npaste.de/aKY3cn0xZf/
>
> --
> Evgeny
>
> _______________________________________________
> 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