[Haskell] Power series in a nutshell
Ryan Ingram
ryani.spam at gmail.com
Mon Jul 16 20:52:38 EDT 2007
This is really interesting. I love how the typechecker can resolve
1:0:1 (representing (1+x^2))
1 : 0 : 1
=> 1 : 0 : (fromInteger 1 :: [Integer])
=> 1 : 0 : (series (fromInteger 1 :: Integer))
=> 1 : 0 : (series 1)
=> 1 : 0 : 1 : repeat 0
(I'm going to go on a bit of a soapbox here...)
I feel that Haskell could learn from one of C++'s goals here: provide
at least as good support for user-defined-types as for built-in types.
Automatic conversion to numeric types via fromInteger could be
extended to other types; fromList and fromString could be applied
automatically to convert other literals:
class LiteralString a where fromString :: String -> a
class LiteralList a b where fromList :: [a] -> b
More information about the Haskell
mailing list