Created
February 11, 2016 11:23
-
-
Save kseo/d516e263fa8c5207d8f5 to your computer and use it in GitHub Desktop.
Polymorphic recursion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Prelude hiding (length) | |
data Nested a = a :<: (Nested [a]) | Epsilon | |
infixr 5 :<: | |
nested = 1 :<: [2,3,4] :<: [[4,5],[7],[8,9]] :<: Epsilon | |
length :: Nested a -> Int | |
length Epsilon = 0 | |
length (_ :<: xs) = 1 + length xs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment