# How to align text right to a line

I want to write a Haskell function definition like this:

But i don't know how to insert that lines.

How can i write something like this in LaTex?

• Welcome to TeX.SE. We usually like to see what you've tried so far; it gives us an idea of what parts we'll need to explain. Have you looked into the listings package? (And I assume you want to typeset something to get that output, as opposed to define a TeX function that would do the same thing as this Haskell function.) – Teepeemm Jun 14 '17 at 2:03
• In the CTAN category "pseudocode" there are a lot of packages which offer functionality to typeset such definition. Just pick one, try to reproduce your picture and then come back with a specific question when you have problems. – Henri Menke Jun 14 '17 at 2:05
• I just want to know how to align formulas right to a vertical line. – Mariano Córdoba Jun 14 '17 at 2:36
• Please update the title of the question to be specific about the vertical and horizontal line that you're trying to reproduce – Will Robertson Jun 14 '17 at 2:43
• I would advise not to vote to close this question yet: give the OP the time to react to the solicitations that have been made. I suggest waiting at least 12 hours since the original post. – GuM Jun 14 '17 at 2:57

Lines drawn with a regular array:

\documentclass{article}

\usepackage{eqparbox,amsmath}

\begin{document}

$\begin{array}{| r @{} l } P ~ : ~ & [\text{Num}] \mapsto \text{Bool} \\ \rule[-10pt]{0pt}{0pt}Q ~ : ~ & \text{Num} \mapsto [\text{Num}] \mapsto \text{Bool} \\ \cline{1-1} \multicolumn{2}{|l}{\rule{0pt}{12pt}\eqmakebox[lhs][r]{P.xs} ~ \doteq ~ Q.0.xs} \\ \multicolumn{2}{|l}{\eqmakebox[lhs][r]{Q.n.[]} ~ \doteq ~ \text{True}} \\ \multicolumn{2}{|l}{\eqmakebox[lhs][r]{Q.n.(x \triangleright xs)} ~ \doteq ~ n \geq 0 \wedge Q.(n + x)xs} \end{array}$

\end{document}


Struts: See Column and row padding in tables