Skip to content

Instantly share code, notes, and snippets.

@folsen
Last active August 29, 2015 14:06
Show Gist options
  • Save folsen/b4594e265d5ead10c2e5 to your computer and use it in GitHub Desktop.
Save folsen/b4594e265d5ead10c2e5 to your computer and use it in GitHub Desktop.
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-}
import qualified Data.HashMap.Strict as HashMap
import Data.Data
import Data.HashMap.Strict (HashMap)
import qualified Data.Vector as Vector
import Data.Vector (Vector)
import Data.Generics.Uniplate.Data
import GHC.Generics
data Expr =
LitInt Int
| LitBool Bool
| Struct (HashMap String Expr)
| Array (Vector Expr)
deriving (Eq, Show, Data, Typeable, Generic)
main :: IO ()
main = do
print $ universe (Struct (HashMap.fromList [("one", LitInt 1), ("false", LitBool False)]))
-- Prints: [Struct (fromList [("one",LitInt 1),("false",LitBool False)]),LitInt 1,LitBool False]
print $ universe (Array (Vector.fromList [LitInt 1, LitBool False]))
-- Prints: [Array (fromList [LitInt 1,LitBool False])]
-- Expected: [Array (fromList [LitInt 1,LitBool False]), LitInt 1,LitBool False]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment