@@ -67,7 +67,7 @@ data Nat = Z | S Nat
6767-- two type-level naturals together. If we do a side-by-side comparison of the
6868-- equivalent "class-based" approach:
6969
70- class Add (x :: Nat ) (y :: Nat ) (z :: Nat ) | x y -> z , z x -> y
70+ class Add (x :: Nat ) (y :: Nat ) (z :: Nat ) | x y -> z
7171type family Add' (x :: Nat ) (y :: Nat ) :: Nat
7272
7373-- | We see here that there are parallels between classes and type families.
@@ -76,7 +76,7 @@ type family Add' (x :: Nat) (y :: Nat) :: Nat
7676-- the result of a type family is determined by its inputs - something we can
7777-- express as a functional dependency!
7878
79- -- | a. Write the two requiredi nstances for the 'Add' class by
79+ -- | a. Write the two required instances for the 'Add' class by
8080-- pattern-matching on the first argument. Remember that instances can have
8181-- constraints, and this is how we do recursion!
8282
@@ -100,7 +100,7 @@ data Proxy (a :: k) = Proxy
100100-- because the names of types are far too confusing. To that end, we can give
101101-- our types friendlier names to make the coding experience less intimidating:
102102
103- class (x :: k ) `IsNamed ` (label :: Symbol ) | x -> label , label -> x where
103+ class (x :: k ) `IsNamed ` (label :: Symbol ) where
104104 fromName :: Proxy x -> Proxy label
105105 fromName _ = Proxy
106106
@@ -241,18 +241,9 @@ instance GNameOf (Rep x) name => NameOf x name
241241class GNameOf (rep :: Type -> Type ) (name :: Symbol ) | rep -> name
242242instance GNameOf (G. D1 ('G.MetaData name a b c ) d ) name
243243
244- -- | a. Read the docs for 'GHC.TypeLits.symbolVal', and write a function that
245- -- takes any generic-implementing type and returns its name as a value-level
246- -- 'String'. For example: @getName True === "Bool"@.
247- 248- -- | b. Write a function to get the names of the constructors of a type as a
244+ -- | Write a function to get the names of the constructors of a type as a
249245-- type-level list of symbols.
250246
251- -- | c. Write a function that returns the names of constructors as value-level
252- -- strings. Note that you might need to check that /all/ members of a
253- -- type-level list implement some constraint... you might need some sort of...
254- -- type-level function...
255- 256247
257248
258249
0 commit comments