Created
April 20, 2016 08:26
-
-
Save christiaanb/ad5b7315142d0b0ade4b50d53562c0a3 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
{-# LANGUAGE PatternSynonyms, ViewPatterns, TypeFamilies #-} | |
module Pat1 (Vec(Nil,(:>)), pattern (:>)) where | |
import qualified Control.Lens as Lens hiding (pattern (:>)) | |
newtype Vec a = Vec {unvec :: [a]} | |
pattern Nil :: Vec a | |
pattern Nil = Vec [] | |
pattern (:>) :: a -> Vec a -> Vec a | |
pattern (:>) x xs <- ((\ys -> (head $ unvec ys,Vec . tail $ unvec ys)) -> (x,xs)) | |
where | |
(:>) x xs = Vec (x:unvec xs) | |
infixl 5 :> | |
type instance Lens.Index (Vec a) = Int |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment