>>> (show ... (+)) 1 2 "3" >>> show ... 5 "5" >>> (null ... zip5) [1] [2] [3] [] [5] TrueInspired by http://stackoverflow.com/questions/9656797/variadic-compose-function.
>>> :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]Remember that Int is a finite type as well. One is unlikely to hit this on a 64-bit architecture, but on a 32-bit machine it's fairly possible to traverse ((0 :: Int) ...) far enough to encounter 0 again.
>>> :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]Remember that Int is a finite type as well: for a sufficiently large step of progression y - x one may observe ((x :: Int, y)....) cycling back to emit x fairly soon.
>>> 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
(f ... g) x y === f (g x y)