>>> (show ... (+)) 1 2 "3" >>> show ... 5 "5" >>> (null ... zip5) [1] [2] [3] [] [5] TrueInspired by http://stackoverflow.com/questions/9656797/variadic-compose-function.
>>> Ix1 4 ... 10 Array D Seq (Sz1 7) [ 4, 5, 6, 7, 8, 9, 10 ]
>>> seriesF @(Hour ... Second) $ hour 3 +:+ minute 5 +:+ sec 3 +:+ ms 123 "3h5m3+123/1000s"
data Auth = Auth { _user ∷ !String , _pwd ∷ !String } user ∷ Functor f ⇒ (String → f String) → Auth → f Auth user f s = (\u → s { _user = u }) <$> f (_user s) pwd ∷ Functor f ⇒ (String → f String) → Auth → f Auth pwd f s = (\p → s { _pwd = p }) <$> f (_pwd s) -- or with lenses and TemplateHaskell just: -- $(makeLenses ''Auth) instance FromJSON (Auth → Auth) where parseJSON = withObject "Auth" $ \o → id <$< user ..: "user" % o <*< pwd ..: "pwd" % o
newtype NonEmpty xs = NonEmpty Defn type role Nonempty nominal -- disallows coercion of Nonempty's argument. newtype Reverse xs = Reverse Defn type role Reverse nominal rev :: ([a] ~~ xs) -> ([a] ~~ Reverse xs) rev xs = defn (reverse (the xs)) rev_nonempty_lemma :: NonEmpty xs -> Proof (NonEmpty (Reverse xs)) rev' :: ([a] ?NonEmpty) -> ([a] ?NonEmpty) rev' = rev ...? rev_nonempty_lemma
>>> :set -XPostfixOperators >>> Data.List.Infinite.take 10 (0...) [0,1,2,3,4,5,6,7,8,9]Beware that for finite types (...) applies cycle atop of [x..]:
>>> :set -XPostfixOperators >>> Data.List.Infinite.take 10 (EQ...) [EQ,GT,EQ,GT,EQ,GT,EQ,GT,EQ,GT]
>>> :set -XPostfixOperators >>> Data.List.Infinite.take 10 ((1,3)....) [1,3,5,7,9,11,13,15,17,19]Beware that for finite types (....) applies cycle atop of [x,y..]:
>>> :set -XPostfixOperators >>> Data.List.Infinite.take 10 ((EQ,GT)....) [EQ,GT,EQ,GT,EQ,GT,EQ,GT,EQ,GT]
(f ... g) x y === f (g x y)