Skip to content

Comment on Beating the Arc Challenge in Haskellparent

Comments

    Dynamic typing is certainly embeddable within Haskell. Just define a data type Dyn which is the sum of types Int, String, Float, [Dyn], and Dyn -> Dyn. You will see how much LISP is possible without much added syntactic cruft. But Haskell users don't need and want to operate in this way, because they can leverage the benefits of static typing.
An enumerated type (as you describe) is very simple to implement, but true dynamic typing is a bit more complicated, and there's some constructs from dynamically-typed languages which can't be expressed within the bounds of Haskell's type system.

The Data.Dynamic[1] module is a pretty good implementation of dynamic typing in Haskell, but it's still a bit awkward to use compared to a language which supports dynamic typing natively (eg Python).

[1] http://www.haskell.org/ghc/docs/latest/html/libraries/base-4...

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.