Skip to content

Commit 119eed5

Browse files
committed
works?
1 parent 6e5ff6b commit 119eed5

File tree

3 files changed

+2
-68
lines changed

3 files changed

+2
-68
lines changed

small/hackory/Hackory.cabal

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,6 @@ build-type: Simple
1212
extra-source-files:
1313
Readme.md
1414

15-
flag production
16-
description: Enable production mode
17-
manual: True
18-
default: False
19-
2015
library
2116
exposed-modules:
2217
Hickory.ImGUI
@@ -26,16 +21,13 @@ library
2621
default-extensions:
2722
NamedFieldPuns
2823
Rank2Types
29-
BangPatterns
3024
OverloadedStrings
3125
ScopedTypeVariables
32-
LambdaCase
3326
TupleSections
34-
ViewPatterns
3527
BlockArguments
3628
RecordWildCards
3729
GHC2021
38-
ghc-options: -Wall -Werror=incomplete-patterns -Wunused-packages -Werror=unused-packages
30+
ghc-options: -Wall -Wunused-packages -Werror=unused-packages -O0
3931
build-depends:
4032
base
4133
, dear-imgui
@@ -44,8 +36,4 @@ library
4436
, lens
4537
, linear
4638
, unordered-containers
47-
if os(osx)
48-
cc-options: -F/System/Library/Frameworks
49-
if flag(production)
50-
cpp-options: -DPRODUCTION
5139
default-language: GHC2021

small/hackory/Hickory/Editor.hs

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,9 @@ import Hickory.ImGUI ()
2929
import Data.Hashable (Hashable)
3030
import Data.Proxy (Proxy (..))
3131

32-
-- Types which have an 'attribute' representation in the editor
3332
class Attr a where
3433
mkAttr :: Attribute a
3534

36-
-- Sometimes the storage type differs (e.g. DearIMGui represents Vec3s as a float triple)
3735
type AttrRef a :: Type
3836
type AttrRef a = a
3937

@@ -49,21 +47,17 @@ typeOfAttr = \case
4947
ColorAttribute -> typeRep
5048

5149
data AttrClasses a where
52-
-- Provides proof of a type having certain instances
5350
AttrClasses :: (Eq a, Eq (AttrRef a)) => AttrClasses a
5451

55-
-- Prove that each attribute has some necessary instances
5652
proveAttrClasses :: Attribute a -> AttrClasses a
5753
proveAttrClasses = \case
5854
ColorAttribute -> AttrClasses
5955

60-
-- Check if two attributes have the same type
6156
eqAttr :: Attribute a1 -> Attribute a2 -> Maybe (a1 :~~: a2)
6257
eqAttr a b = eqTypeRep (typeOfAttr a) (typeOfAttr b)
6358

6459
data SomeAttribute contents = forall a. Attr a => SomeAttribute { attr :: Attribute a, contents :: contents a }
6560

66-
-- Look up the value for an attribute
6761
withAttrVal :: forall a b k. (Attr a, Hashable k) => HashMap k (SomeAttribute Identity) -> k -> (a -> b) -> b
6862
withAttrVal attrs name f = case Map.lookup name attrs of
6963
Just (SomeAttribute attr (Identity v)) -> case eqAttr attr (mkAttr :: Attribute a) of
@@ -79,19 +73,14 @@ mkDefaultComponent :: [SomeAttribute (Const String)] -> HashMap String (SomeAttr
7973
mkDefaultComponent xs = Map.fromList $ xs <&> \case
8074
SomeAttribute attr (Const name) -> (name, SomeAttribute attr (Identity $ defaultAttrVal attr))
8175

82-
{- Generics -}
83-
8476
class GRecordAttributes (f :: Type -> Type) where
8577
gToAttributeList :: Proxy f -> [SomeAttribute (Const String)]
8678
gFromHashMap :: HashMap String (SomeAttribute Identity) -> f p
8779

88-
-- Empty constructor
8980
instance GRecordAttributes U1 where
9081
gToAttributeList _ = []
9182
gFromHashMap _ = U1
9283

93-
-- For metadata that doesn't affect structure (the D and C metadata),
94-
-- we just pass through to the contained representation.
9584
instance GRecordAttributes f => GRecordAttributes (M1 D x f) where
9685
gToAttributeList _ = gToAttributeList (Proxy :: Proxy f)
9786
gFromHashMap hm = M1 (gFromHashMap hm)
@@ -100,27 +89,6 @@ instance GRecordAttributes f => GRecordAttributes (M1 C x f) where
10089
gToAttributeList _ = gToAttributeList (Proxy :: Proxy f)
10190
gFromHashMap hm = M1 (gFromHashMap hm)
10291

103-
instance (GRecordAttributes f, GRecordAttributes g)
104-
=> GRecordAttributes (f :*: g) where
105-
gToAttributeList _ =
106-
gToAttributeList (Proxy :: Proxy f) ++ gToAttributeList (Proxy :: Proxy g)
107-
gFromHashMap hm =
108-
let left = gFromHashMap hm
109-
right = gFromHashMap hm
110-
in left :*: right
111-
112-
-- A single field
113-
instance (Selector s, Attr a) => GRecordAttributes (M1 S s (K1 i a)) where
114-
gToAttributeList _ =
115-
let fieldName = selName (undefined :: M1 S s (K1 i a) p)
116-
in [ SomeAttribute (mkAttr @a) (Const fieldName) ]
117-
gFromHashMap hm =
118-
let fieldName = selName (undefined :: M1 S s (K1 i a) p)
119-
val = withAttrVal hm fieldName id
120-
in M1 (K1 val)
121-
122-
{- Generic GLSL struct definitions -}
123-
12492
class GlslType a where
12593
glslTypeName :: Proxy a -> String
12694

@@ -138,12 +106,6 @@ instance GHasGlslUniformDef f => GHasGlslUniformDef (M1 D x f) where
138106
instance GHasGlslUniformDef f => GHasGlslUniformDef (M1 C x f) where
139107
gGlslLines _ = gGlslLines (Proxy :: Proxy f)
140108

141-
instance (GHasGlslUniformDef f, GHasGlslUniformDef g)
142-
=> GHasGlslUniformDef (f :*: g) where
143-
gGlslLines _ =
144-
gGlslLines (Proxy :: Proxy f) ++
145-
gGlslLines (Proxy :: Proxy g)
146-
147109
instance (Selector s, GlslType a)
148110
=> GHasGlslUniformDef (M1 S s (K1 i a)) where
149111
gGlslLines _ =

small/hackory/package.yaml

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,19 @@ name: Hackory
22

33
ghc-options:
44
- -Wall
5-
- -Werror=incomplete-patterns
65
- -Wunused-packages
76
- -Werror=unused-packages
7+
- -O0
88

99
extra-source-files:
1010
- Readme.md
1111

1212
default-extensions:
1313
- NamedFieldPuns
1414
- Rank2Types
15-
- BangPatterns
1615
- OverloadedStrings
1716
- ScopedTypeVariables
18-
- LambdaCase
1917
- TupleSections
20-
- ViewPatterns
2118
- BlockArguments
2219
- RecordWildCards
2320
- GHC2021
@@ -31,22 +28,9 @@ dependencies:
3128
- linear
3229
- unordered-containers
3330

34-
flags:
35-
production:
36-
description: Enable production mode
37-
manual: true
38-
default: false
39-
40-
when:
41-
- condition: os(osx)
42-
cc-options: -F/System/Library/Frameworks
43-
4431
library:
4532
verbatim:
4633
default-language: GHC2021
47-
when:
48-
- condition: "flag(production)"
49-
cpp-options: -DPRODUCTION
5034

5135
exposed-modules:
5236
- Hickory.ImGUI

0 commit comments

Comments
 (0)