Skip to content

Commit 6eb24c8

Browse files
committed
fix: Synthesus should use SafeLookup constraint.
1 parent 88d6163 commit 6eb24c8

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

app/Synthesis.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,11 @@ main = do
8686

8787
clean ::
8888
( DT.AssertPresent "Ticket" cols
89-
, DT.Lookup "Ticket" cols ~ Maybe T.Text
89+
, DT.SafeLookup "Ticket" cols ~ Maybe T.Text
9090
, DT.AssertPresent "Name" cols
91-
, DT.Lookup "Name" cols ~ Maybe T.Text
91+
, DT.SafeLookup "Name" cols ~ Maybe T.Text
9292
, DT.AssertPresent "Cabin" cols
93-
, DT.Lookup "Cabin" cols ~ Maybe T.Text
93+
, DT.SafeLookup "Cabin" cols ~ Maybe T.Text
9494
) =>
9595
DT.TypedDataFrame cols ->
9696
DT.TypedDataFrame

src/DataFrame/Typed/Schema.hs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,10 @@ type family Lookup (name :: Symbol) (cols :: [Type]) :: Type where
7777
TypeError
7878
('Text "Column '" ':<>: 'Text name ':<>: 'Text "' not found in schema")
7979

80-
-- | Like 'Lookup', but returns a harmless fallback ('Int') instead of
81-
-- 'TypeError' when the column is not found. Use together with
82-
-- 'AssertPresent' so the error fires exactly once.
80+
{- | Like 'Lookup', but returns a harmless fallback ('Int') instead of
81+
'TypeError' when the column is not found. Use together with
82+
'AssertPresent' so the error fires exactly once.
83+
-}
8384
type family SafeLookup (name :: Symbol) (cols :: [Type]) :: Type where
8485
SafeLookup name (Column name a ': _) = a
8586
SafeLookup name (Column _ _ ': rest) = SafeLookup name rest

0 commit comments

Comments
 (0)