Created
June 13, 2016 18:56
-
-
Save abbradar/6d85ea7db99313e91ee837f02735009f to your computer and use it in GitHub Desktop.
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
{-# LANGUAGE PatternSynonyms, ViewPatterns #-} | |
import Data.List | |
import Data.Foldable | |
import Control.Monad.State | |
import Data.Distributive | |
fromList :: (Applicative m, Distributive m, Traversable m) => [a] -> Maybe (m a) | |
fromList xs = do | |
(ys, []) <- runStateT (traverse (\_ -> StateT uncons) (pure ())) xs | |
return ys | |
pattern FixedList :: (Distributive m, Traversable m, Applicative m) => m a -> [a] | |
pattern FixedList m <- (fromList -> Just m) where | |
FixedList m = toList m |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment