Amar Nath Satrawala
| Forum | Thread | Replies | Latest activity |
|---|---|---|---|
| Tech Off | Haskell question | 2 | Feb 02, 2010 at 7:57 AM |
Loading User Information from Channel 9
Something went wrong getting user information from Channel 9
Loading User Information from MSDN
Something went wrong getting user information from MSDN
Loading Visual Studio Achievements
Something went wrong getting the Visual Studio Achievements
| Forum | Thread | Replies | Latest activity |
|---|---|---|---|
| Tech Off | Haskell question | 2 | Feb 02, 2010 at 7:57 AM |
C9 Lectures: Dr. Erik Meijer - Functional Programming Fundamentals Chapter 10 of 13
Feb 02, 2010 at 8:57 AMEric, a very late question
In object oriented languages, we have the flexibility of defining sub-classes late after super class has been defined. The two definitions need not be done simultaneously. Moreover, there is no limit on the number of sub-classes baring the case of sealed types (which could still be circumvented using containment and defining casts).
In relation to the analogy of algebraic types and class hierarchies, what is the way in Haskell to extend the types as we can do in object oriented languages.
For example:
data Answer = No | Yes
data AnswerEx = FromAnswer Answer | Unknown
fromAnswerEx :: AnswerEx -> Answer
fromAnswerEx FromAnswer a = a
fromAnswerEx Unknown = No -- in Haskell we have to generate a value of Answer type here
We could surely define functions for explicit conversion e.g. fromAnswerEx but the compiles can not use them automatically. In code given below we have to use the explicit conversions.
answers = [Yes, No, fromAnswerEx Unknown, fromAnswerEx FromAnswer Yes]
The following will not work.
answers = [Yes, No, Unknown, FromAnswer Yes]
It is possible there in object oriented languages.
Is there any pattern/idiom in Haskell to achieve same?
Erik Meijer and Matthew Podwysocki - Perspectives on Functional Programming
May 30, 2009 at 12:40 AMI am into moving into functional programming (Haskell, F#) for the last few months. I have read Expert F#, Real World Haskell etc.
I am liking the ideas and styles and started coding some fun stuff with great things there in F#.
I was disappointed by the quality (succinctness and clarity) of this video compared to other numerous videos which I have seen from c9 or msdn. (Maybee worst of all which I have seen) Sorry, Matthew and Eric, but I missed the flow and stopped watching the video in the middle.
I am sorry if I am rude but I got one point from this lecture that intellisence is some kind of bad thing. The examples could have been given either in pseudo code (without any reference to syntax) or with correct syntax of either F# or Haskell.