Skip to content

Commit

Permalink
moved elm code to the end
Browse files Browse the repository at this point in the history
  • Loading branch information
Dobiasd committed Nov 18, 2013
1 parent 96faed1 commit 7e0c8eb
Showing 1 changed file with 29 additions and 25 deletions.
54 changes: 29 additions & 25 deletions from_oop_to_fp_-_inheritance_and_the_expression_problem.md
Original file line number Diff line number Diff line change
Expand Up @@ -455,8 +455,34 @@ main =
displayAll l'
```

Finally let's check if this can be translated to
[Elm](http://elm-lang.org/learn/Syntax.elm)
## Conclusion

Yeah, and that is it.
Of course, we did not *solve* the expression problem, but thanks to the fact
that we can handle functions as data in FP,
at least we can now choose which side of the problem we want to face.
We can have our desired comfort for software that often gets
new types and rarely new functions, despite the presence of a
stong static type system. We now can invent hundreds of new subtypes like
[baz and qux](http://en.wikipedia.org/wiki/List_of_recurring_Mario_franchise_enemies)
and easily add them to our world.
We do not have to edit central monster functions for the actions of all the
different types.
Everything is neatly arranged in the modules of the actual type.

---------------------------------------

If there already is a more idiomatic solution in Haskell for this, or you
have an Idea for a more elegant approach, please [tell](mailto:harry@daiw.de)
[me](https://www.facebook.com/Dohbi). :)

---------------------------------------

## Elm version

If you are interested to use this in
[Elm](http://elm-lang.org/learn/Syntax.elm), the translation looks as
follows:

```haskell
-- Base.elm
Expand Down Expand Up @@ -527,26 +553,4 @@ main =
in
-- Show result.
plainText <| displayAll l'
```
It does.

## Conclusion

Yeah, and that is it.
Of course, we did not *solve* the expression problem, but thanks to the fact
that we can handle functions as data in FP,
at least we can now choose which side of the problem we want to face.
We can have our desired comfort for software that often gets
new types and rarely new functions, despite the presence of a
stong static type system. We now can invent hundreds of new subtypes like
[baz and qux](http://en.wikipedia.org/wiki/List_of_recurring_Mario_franchise_enemies)
and easily add them to our world.
We do not have to edit central monster functions for the actions of all the
different types.
Everything is neatly arranged in the modules of the actual type.

---------------------------------------

If there already is a more idiomatic solution in Haskell for this, or you
have an Idea for a more elegant approach, please [tell](mailto:harry@daiw.de)
[me](https://www.facebook.com/Dohbi). :)
```

0 comments on commit 7e0c8eb

Please sign in to comment.