News for hackers. Stuff that matters.
Re:A Pythonista's Review of Haskell by ridiculous_fish on Friday January 31, 2020 @12:56AM (#22199456)
Note many dynamically typed languages have static types. Objective-C, Java, TypeScript, Dart, etc. The dynamic types bring new capabilities above and beyond what is possible with static types.

(That is, the dynamic-or-static choice is a product type, not a sum type!)

Re:A Pythonista's Review of Haskell by greydius on Friday January 31, 2020 @01:18AM (#22199547)
> The dynamic types bring new capabilities above and beyond what is possible with static types.

Not really. "Dynamic type" just means an object that carries around a description of its structure (or more commonly, a pointer to a description). You can do the same thing in many languages with static types. (Including Haskell. GHC has special support for this pattern.)

Re:A Pythonista's Review of Haskell by giornogiovanna on Friday January 31, 2020 @05:03AM (#22200421)
What special support does GHC have?
Re:A Pythonista's Review of Haskell by nybble41 on Friday January 31, 2020 @12:52PM (#22203741)
GHC can derive a Typeable type class instance for any data type which allows values of that type to be stored in a Dynamic wrapper. For soundness reasons the Typeable type class is special in that it can only be derived; you can't implement it manually. The runtime types of Dynamic values can be queried and compared and you can attempt to extract a specific known (concrete) type, which will succeed only if the runtime type matches. There are some limitations; for example, you need to know the exact type of the value you're extracting, not just a type class constraint, so you can't e.g. add two Dynamic values directly even if they hold the same type of value at runtime with a valid Num instance.

Alternatively, you can just define a recursive sum type expressing all the possible runtime types of the dynamic expression. In Aeson for example there is a type which can encode any value which might be found in a JSON file, which is basically everything you can express in Javascript apart from function closures. This doesn't require any special support from GHC and works well in most statically-typed languages.