Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 748c0a2

Browse files
author
Tom Harding
authored
Small fixes
Filling in the answers and realising that some of the questions require things we haven't yet covered >_<
1 parent fbb2451 commit 748c0a2

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

‎10-FunctionalDependencies/src/Exercises.hs‎

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -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, zx->y
70+
class Add (x :: Nat) (y :: Nat) (z :: Nat) | x y -> z
7171
type 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->xwhere
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
241241
class GNameOf (rep :: Type -> Type) (name :: Symbol) | rep -> name
242242
instance 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

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /