Last active
August 29, 2015 14:06
-
-
Save folsen/b4594e265d5ead10c2e5 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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