Skip to content

Instantly share code, notes, and snippets.

@rpglover64
Last active August 29, 2015 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rpglover64/1cee031f249ead059970 to your computer and use it in GitHub Desktop.
Save rpglover64/1cee031f249ead059970 to your computer and use it in GitHub Desktop.
Using OverloadedLists and applicative-quoters together.
{-# 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