@@ -322,12 +322,17 @@ getClause :: Int -- ^ line number that the type is declared on
322 -> Name -- ^ Function name
322 -> Name -- ^ Function name
323 -> FilePath -- ^ Source file name
323 -> FilePath -- ^ Source file name
324 -> Idris String
324 -> Idris String
327+ case lookupCtxt fn (idris_classes i) of
328+ [c] -> return (mkClassBodies i (class_methods c))
325−getClause l fn fp = do ty <- getInternalApp fp l
329+ _ -> do ty <- getInternalApp fp l
326− ist <- get
330+ ist <- get
327− let ap = mkApp ist ty []
331+ let ap = mkApp ist ty []
328− return (show fn ++ " " ++ ap ++
332+ return (show fn ++ " " ++ ap ++ "= ?"
329− "= ?" ++ show fn ++ "_rhs")
333+ ++ show fn ++ "_rhs")
334+ where mkApp :: IState -> PTerm -> [Name] -> String
330− where mkApp i (PPi (Exp _ _ False) (MN _ _) ty sc) used
335+ mkApp i (PPi (Exp _ _ False) (MN _ _) ty sc) used
331 = let n = getNameFrom i used ty in
336 = let n = getNameFrom i used ty in
332 show n ++ " " ++ mkApp i sc (n : used)
337 show n ++ " " ++ mkApp i sc (n : used)
333 mkApp i (PPi (Exp _ _ False) (UN n) ty sc) used
338 mkApp i (PPi (Exp _ _ False) (UN n) ty sc) used
@@ -349,6 +354,19 @@ getClause l fn fp = do ty <- getInternalApp fp l
349 ns -> uniqueNameFrom (mkSupply ns) used
354 ns -> uniqueNameFrom (mkSupply ns) used
350 getNameFrom i used _ = uniqueName (sUN "x") used
355 getNameFrom i used _ = uniqueName (sUN "x") used
357+ -- write method declarations, indent with 4 spaces
358+ mkClassBodies :: IState -> [(Name, (FnOpts, PTerm))] -> String
361+ (zipWith (\(n, (_, ty)) m -> " " ++
362+ def (show (nsroot n)) ++ " "
365+ ++ show fn ++ "_rhs_" ++ show m) ns [1..])
367+ def n@(x:xs) | not (isAlphaNum x) = "(" ++ n ++ ")"
352getProofClause :: Int -- ^ line number that the type is declared
370getProofClause :: Int -- ^ line number that the type is declared
353 -> Name -- ^ Function name
371 -> Name -- ^ Function name
354 -> FilePath -- ^ Source file name
372 -> FilePath -- ^ Source file name