Created
May 7, 2018 14:36
-
-
Save joneshf/13888e9c8d3d231297cddb760891f944 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
module Main where | |
import Prelude | |
import Data.Foldable (class Foldable, foldl) | |
import Data.Maybe (Maybe(Just, Nothing)) | |
data NonEmpty a = NonEmpty a (Array a) | |
instance foldableNonEmpty :: Foldable NonEmpty where | |
foldl f acc (NonEmpty a as) = case ?somethingThatGivesAMaybe as of | |
Just x -> foldl f (f acc a) (NonEmpty x.head x.tail) | |
Nothing -> f acc a | |
foldr = ?foldr | |
foldMap = ?foldMap |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment