Last active
August 29, 2015 14:15
-
-
Save rpglover64/1cee031f249ead059970 to your computer and use it in GitHub Desktop.
Using OverloadedLists and applicative-quoters together.
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 TypeFamilies #-} | |
{-# LANGUAGE OverloadedLists #-} | |
{-# LANGUAGE QuasiQuotes #-} | |
import GHC.Exts | |
import Control.Applicative | |
import Control.Applicative.QQ.Idiom | |
-- Note that this is an orphan instance. | |
instance IsList (ZipList a) where | |
type Item (ZipList a) = a | |
fromList = ZipList | |
toList = getZipList | |
main = do | |
(print . getZipList) [i| (+) [1,2,3] [4,5,6] |] | |
(print . getZipList) [i| (+) (pure 7) [5..9] |] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment