Skip to content

Instantly share code, notes, and snippets.

@NorfairKing
Created September 5, 2025 12:21
Show Gist options
  • Save NorfairKing/64e531869e1de6d2596cfa5f8da05913 to your computer and use it in GitHub Desktop.
Save NorfairKing/64e531869e1de6d2596cfa5f8da05913 to your computer and use it in GitHub Desktop.
selectUnValued :: (MonadIO m, UnValueAll a a', SqlSelect (SqlExpr a) a) => SqlQuery (SqlExpr a) -> SqlPersistT m [a']
selectUnValued = fmap (map unValueAll) . select
unValueAll :: (UnValueAll a a') => a -> a'
unValueAll = unV
class UnValueAll a b where
unV :: a -> b
instance UnValueAll (Value a) a where
unV (Value a) = a
instance UnValueAll (Entity a) (Entity a) where
unV = id
instance UnValueAll (Maybe (Entity a)) (Maybe (Entity a)) where
unV = id
instance (UnValueAll a a', UnValueAll b b') => UnValueAll (a, b) (a', b') where unV (a, b) = (unV a, unV b)
instance (UnValueAll a a', UnValueAll b b', UnValueAll c c') => UnValueAll (a, b, c) (a', b', c') where unV (a, b, c) = (unV a, unV b, unV c)
instance (UnValueAll a a', UnValueAll b b', UnValueAll c c', UnValueAll d d') => UnValueAll (a, b, c, d) (a', b', c', d') where unV (a, b, c, d) = (unV a, unV b, unV c, unV d)
instance (UnValueAll a a', UnValueAll b b', UnValueAll c c', UnValueAll d d', UnValueAll e e') => UnValueAll (a, b, c, d, e) (a', b', c', d', e') where unV (a, b, c, d, e) = (unV a, unV b, unV c, unV d, unV e)
instance (UnValueAll a a', UnValueAll b b', UnValueAll c c', UnValueAll d d', UnValueAll e e', UnValueAll f f') => UnValueAll (a, b, c, d, e, f) (a', b', c', d', e', f') where unV (a, b, c, d, e, f) = (unV a, unV b, unV c, unV d, unV e, unV f)
instance (UnValueAll a a', UnValueAll b b', UnValueAll c c', UnValueAll d d', UnValueAll e e', UnValueAll f f', UnValueAll g g') => UnValueAll (a, b, c, d, e, f, g) (a', b', c', d', e', f', g') where unV (a, b, c, d, e, f, g) = (unV a, unV b, unV c, unV d, unV e, unV f, unV g)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment