Skip to content

Instantly share code, notes, and snippets.

@hadronized
Last active August 29, 2015 14:24
Show Gist options
  • Save hadronized/733d26802f5ae525cb3a to your computer and use it in GitHub Desktop.
Save hadronized/733d26802f5ae525cb3a to your computer and use it in GitHub Desktop.
struct Widget {
virtual ~Widget();
virtual void foo() = 0;
};
class Label : public Widget {
std::string _value;
public:
Label(std::string const &v) : _value(v) {}
~Label() {}
override void foo() {
std::cout << _value << std::endl;
}
};
data Widget = Widget {
foo :: IO ()
}
data Label = Label String
toWidget :: Label -> Widget
toWidget (Label str) = Widget $ putStrLn str
-- encore mieux, pour gérer plus de widgets par la suite
data Widget = Widget {
foo :: IO ()
}
class ToWidget a where
toWidget :: a -> Widget
data Label = Label String
instance ToWidget Label where
toWidget (Label str) = Widget $ putStrLn str
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment