Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add warning -fwarn-incomplete-patterns in Types.hs #246

Merged
merged 2 commits into from
Oct 8, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/types/Types.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{-# LANGUAGE TypeSynonymInstances #-}
{-# LANGUAGE FlexibleInstances #-}
{-# OPTIONS_GHC -fwarn-incomplete-patterns #-}
module Types(
Type
, Capability
Expand Down Expand Up @@ -133,6 +134,7 @@ data Capability = Capability { typeTree :: TypeTree }
deriving (Eq)

instance Show Capability where
show EmptyCapability = ""
show Capability{typeTree} = show typeTree

data RefInfo = RefInfo{refId :: String
Expand Down Expand Up @@ -288,6 +290,7 @@ refInfoTypeComponents = concatMap typeComponents . parameters

-- TODO: Should maybe extract the power set?
capabilityComponents :: Capability -> [Type]
capabilityComponents EmptyCapability = []
capabilityComponents Capability{typeTree} =
concatMap traitToType $ toList typeTree
where
Expand Down Expand Up @@ -323,6 +326,7 @@ refInfoTypeMap f info@RefInfo{parameters} =
info{parameters = map (typeMap f) parameters}

capabilityTypeMap :: (Type -> Type) -> Capability -> Capability
capabilityTypeMap _ EmptyCapability = EmptyCapability
capabilityTypeMap f cap@Capability{typeTree} =
cap{typeTree = fmap (refInfoTypeMap f) typeTree}

Expand Down Expand Up @@ -411,6 +415,8 @@ conjunctiveTypesFromCapability ty@CapabilityType{capability} =
parTypes = map toList $ map (fmap TraitType) ts
in
concatMap collect ts ++ [parTypes]
conjunctiveTypesFromCapability ty =
error $ "Types.hs: Cannot get conjunctive types from " ++ showWithKind ty

typesFromCapability :: Type -> [Type]
typesFromCapability t@TraitType{} = [t]
Expand Down